Fabien Meghazi wrote:
Maybe what I want to do is pointless or too complicated.
I'm curious to know how do you manage double client/server side
validation in your applications ?
No, its no pointless at all. Its a very important issue, something I'd like to deal with on a more long term issue. So far I've concentrated on the client side.

So far I'm using the validation plugin in one application, using JSF as the serverside MVC framework. Defining basic validation rules looks like this:

<h:inputText value="${search.term}" required="true" styleClass="{required:true}" 
/>


That tag produces something like this:

<input type="text" name="someformid:_term" class="{required:true}" />

A better solution would generate the additional class info as soon as I'm specifying required="true". That isn't too hard to achieve with JSF.

The good thing of this approach is that you can simply select a forms on your page (maybe filtered by a marked class like "validate") and apply the validation plugin to it. Rules are defined inline, so you don't have any issues associating rules with fields.

The bad thing is all that inline stuff that is meaningless without JS. More complex validation rules, like dynamic dependency-checks, can mess up your markup.

I recommend to build a solution that generates JSON used by the validation plugin, based on some serverside rules. I see the biggest difficulty with linking rules to forms and fields.

--
Jörn Zaefferer

http://bassistance.de

Reply via email to