You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Inge Solvoll <in...@gmail.com> on 2008/03/31 10:30:47 UTC

T5: Custom (conditional) validation

Hi!

I'm reading the examples on TextField validation, which use
validate="required,regexp" for specifying validation rules.

A lot of my pages use more sophisticated validation, examples here:

- Field1 is only required if Field2 is empty
- This is a temp save (save draft), so none of the fields are required, even
though they should be required on normal submit.

These are very common cases for me, and I'm struggling a bit in T4 to
implement this in an elegant way (as elegant as default validation markup).
Could someone point me to documentation/mailing list post that shows elegant
solutions for this in T5 (or even better, in T4). I couldn't possibly be the
first one to comment on this? :)

In Struts 1.3.8, I find the default validation system so painful and hard to
debug that I actually choose to write custom java code for all my
validation, to have full control over the logic. Far from ideal, but in my
opinion better than the built-in alternative. I'm really hoping that I can
find a far better solution to advanced validation needs in Tapestry!

Thanks

Inge

Re: T5: Custom (conditional) validation

Posted by Marcus Schulte <et...@googlemail.com>.
Hi Inge,

I've done similar conditional validation using T4-1's  ajax - @EventListener
stuff. This is certainly not the tersest possible solution, but it's very
powerful. And, most importantly, client-side validation works.


So you might have something like:


...

<input jwcid="txt1@TextField" value="ognl:t1"  />

<input jwcid="txt2@TextField" value="ognl:t2"
validators="ognl:txt2Validators" />

...


and:


...

   IValidator[] getTxt2Validators() {

return getT1() == null ?

new IValidator[]{new RequiredValidator(), ...}

        : new IValidator[0] }


 @EventListener( events = "onchange", target="txt1" )

 public void onT2changed() {

getRequestCycle().getResponseRenderer().updateComponent("txt2");

 }

...


Marcus


On 31/03/2008, Inge Solvoll <in...@gmail.com> wrote:
>
> Hi!
>
> I'm reading the examples on TextField validation, which use
> validate="required,regexp" for specifying validation rules.
>
> A lot of my pages use more sophisticated validation, examples here:
>
> - Field1 is only required if Field2 is empty
> - This is a temp save (save draft), so none of the fields are required,
> even
> though they should be required on normal submit.
>
> These are very common cases for me, and I'm struggling a bit in T4 to
> implement this in an elegant way (as elegant as default validation
> markup).
> Could someone point me to documentation/mailing list post that shows
> elegant
> solutions for this in T5 (or even better, in T4). I couldn't possibly be
> the
> first one to comment on this? :)
>
> In Struts 1.3.8, I find the default validation system so painful and hard
> to
> debug that I actually choose to write custom java code for all my
> validation, to have full control over the logic. Far from ideal, but in my
> opinion better than the built-in alternative. I'm really hoping that I can
> find a far better solution to advanced validation needs in Tapestry!
>
> Thanks
>
>
> Inge
>



-- 
Marcus Schulte
http://marcus-schulte.blogspot.com

RE: T5: Custom (conditional) validation

Posted by Cordenier Christophe <Ch...@atosorigin.com>.
Hello

You may take a look at the ValidationTracker mechanism. Form uses this objects to follow form errors.
The form component has the "tracker" attribute to substitute the default one by yours.

Hope this helps

Christophe

-----Message d'origine-----
De : Inge Solvoll [mailto:inge.tapestry@gmail.com]
Envoyé : lundi 31 mars 2008 10:31
À : Tapestry users
Objet : T5: Custom (conditional) validation

Hi!

I'm reading the examples on TextField validation, which use
validate="required,regexp" for specifying validation rules.

A lot of my pages use more sophisticated validation, examples here:

- Field1 is only required if Field2 is empty
- This is a temp save (save draft), so none of the fields are required, even
though they should be required on normal submit.

These are very common cases for me, and I'm struggling a bit in T4 to
implement this in an elegant way (as elegant as default validation markup).
Could someone point me to documentation/mailing list post that shows elegant
solutions for this in T5 (or even better, in T4). I couldn't possibly be the
first one to comment on this? :)

In Struts 1.3.8, I find the default validation system so painful and hard to
debug that I actually choose to write custom java code for all my
validation, to have full control over the logic. Far from ideal, but in my
opinion better than the built-in alternative. I'm really hoping that I can
find a far better solution to advanced validation needs in Tapestry!

Thanks

Inge


Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org