You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Norris <th...@gmail.com> on 2011/03/25 17:23:25 UTC

Runtime configurable Validators in T5... this was easy in T4

In T4 we could new up a Validator, provide it with whatever
information we wanted, and pass that directly to a form component for
validation. I miss this.

I have a loop which generates form components. Each one needs some
very custom validation. I know I can create a validator that will take
in a constraint, but the constraint in the template has to be static.
I could inject a FieldValidatorSource, but that requires having access
to the Field, which I don't because they are generated in a loop. I
can't just inject them all into the page.

I can accomplish all this with an onValidate method, but then the only
thing I can do is add generic errors to the ValidationTracker. I can't
specify which field is in error because the fields are generated in a
loop and therefore can't be injected into the page.

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


Re: Runtime configurable Validators in T5... this was easy in T4

Posted by Chris Norris <th...@gmail.com>.
Ah, thank you for pointing out the obvious. I was still thinking in
terms of Validators, and was trying to make a validator to provide to
a FieldValidatorImpl rather than just implementing FieldValidator
myself. I cannot believe how entrenched in that line of thinking I
was.

On Fri, Mar 25, 2011 at 12:56 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Fri, 25 Mar 2011 13:23:25 -0300, Chris Norris
> <th...@gmail.com> wrote:
>
>> I have a loop which generates form components. Each one needs some
>> very custom validation. I know I can create a validator that will take
>> in a constraint, but the constraint in the template has to be static.
>
> This is not correct. The default validate parameter binding is validate, but
> you can use prop:validator and have a getValidator() method that returns a
> FieldValidator instance.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: Runtime configurable Validators in T5... this was easy in T4

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 25 Mar 2011 13:23:25 -0300, Chris Norris  
<th...@gmail.com> wrote:

> I have a loop which generates form components. Each one needs some
> very custom validation. I know I can create a validator that will take
> in a constraint, but the constraint in the template has to be static.

This is not correct. The default validate parameter binding is validate,  
but you can use prop:validator and have a getValidator() method that  
returns a FieldValidator instance.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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