You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by mraible <ma...@raibledesigns.com> on 2009/05/03 19:55:37 UTC

Tapestry 5 Validation

Is it possible to do validation declaratively, or rather - only at the web
tier? AFAIK, I can only do validation with 1) annotations on the model
object or 2) manually with if (blank) logic in my Page. 

Thanks,

Matt
-- 
View this message in context: http://www.nabble.com/Tapestry-5-Validation-tp23358011p23358011.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry 5 Validation

Posted by cfineman <cf...@gmail.com>.
Do you mean javascript validation? The beanform seems to support using things
like scriptalicious to implement client-side validation (of the declarative
constraints specified at the page level). I didn't see any evidence that the
"leaf" core components support this.

I did find some info at:
http://tapestry.formos.com/nightly/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/BeanEditForm.html

You might get some insight by digging around that the BeanEditForm
implementation (sorry... I know that's not much of an answer :teeth: )



mraible wrote:
> 
> Is it possible to do validation declaratively, or rather - only at the web
> tier? AFAIK, I can only do validation with 1) annotations on the model
> object or 2) manually with if (blank) logic in my Page. 
> 
> Thanks,
> 
> Matt
> 

-- 
View this message in context: http://www.nabble.com/Tapestry-5-Validation-tp23358011p23360560.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry 5 Validation

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 04 May 2009 20:47:47 -0300, Thiago H. de Paula Figueiredo  
<th...@gmail.com> escreveu:

> Em Mon, 04 May 2009 19:42:39 -0300, Robert Zeigler <ro...@scazdl.org>  
> escreveu:
>
>> Well, the ValidationConstraintGenerator basically serves this purpose,  
>> no? You can contribute any sort of constraint generator, neh?
>
> You've just introduced it to me. :) Thanks for pointing it out. I'll  
> play with it now to figure out if it is the solution I'm looking for.

Robert, thank you again. It's exactly what I was looking for. :)

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Tapestry 5 Validation

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 04 May 2009 19:42:39 -0300, Robert Zeigler <ro...@scazdl.org>  
escreveu:

> Well, the ValidationConstraintGenerator basically serves this purpose,  
> no? You can contribute any sort of constraint generator, neh?

You've just introduced it to me. :) Thanks for pointing it out. I'll play  
with it now to figure out if it is the solution I'm looking for.

> For instance, the tapestry5-cayenne module contributes one that gleans  
> the validation info from mapping metadata.

I'll take a look at that too. ;)

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Tapestry 5 Validation

Posted by Robert Zeigler <ro...@scazdl.org>.
On May 4, 2009, at 5/45:19 PM , Thiago H. de Paula Figueiredo wrote:

> Em Mon, 04 May 2009 18:58:24 -0300, Robert Zeigler  
> <ro...@scazdl.org> escreveu:
>> I think it would be useful, however, to be able to define the set  
>> of validators to use in a message catalog.
>
> +1 to that. By the way, I think it would be very nice to have  
> something like a pipeline to provide validation to fields. Support  
> for validation based on JPA, Hibernate, Hibernate Validator and Bean  
> Validation (JSR 303, still in beta) annotations or any other source  
> of validation rules (including message catalogs).
>

Well, the ValidationConstraintGenerator basically serves this purpose,  
no? You can contribute any sort of constraint generator, neh?
For instance, the tapestry5-cayenne module contributes one that gleans  
the validation info from mapping metadata.

>> That would entail a new ValidationConstraintGenerator, except...  
>> there's no simple way for a ValidationConstraintGenerator  
>> implementation to gain access to the message catalog for the page  
>> or component that holds the component for which the constraints  
>> should be generated.  The behavior I described above is handled at  
>> a level outside of the constraint generator.  Still... if you add  
>> an issue, I'll grab it and explore options.
>
> At least we could use the global message catalog (app.properties).

Yeah.... but it would be nice to be able to tie things down a bit more  
specifically to a particular page or component.

Robert

>
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> 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: Tapestry 5 Validation

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 04 May 2009 18:58:24 -0300, Robert Zeigler <ro...@scazdl.org>  
escreveu:
> I think it would be useful, however, to be able to define the set of  
> validators to use in a message catalog.

+1 to that. By the way, I think it would be very nice to have something  
like a pipeline to provide validation to fields. Support for validation  
based on JPA, Hibernate, Hibernate Validator and Bean Validation (JSR 303,  
still in beta) annotations or any other source of validation rules  
(including message catalogs).

> That would entail a new ValidationConstraintGenerator, except... there's  
> no simple way for a ValidationConstraintGenerator implementation to gain  
> access to the message catalog for the page or component that holds the  
> component for which the constraints should be generated.  The behavior I  
> described above is handled at a level outside of the constraint  
> generator.  Still... if you add an issue, I'll grab it and explore  
> options.

At least we could use the global message catalog (app.properties).

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Tapestry 5 Validation

Posted by Robert Zeigler <ro...@scazdl.org>.
To be honest, I hadn't used it. I looked at it more closely, and it  
won't do /quite/ what you want.
Tapestry will look up the /constraints/ to use for a particular  
validator in the message catalog for the containing page/component,
but it won't look up the actual /validators/ to use.
So if you had:
<t:textfield validate="required,regexp"/>

You could include:

fieldid-regexp=^[a-zA-Z]+$

and that would be the regular expression for your validator.

I think it would be useful, however, to be able to define the set of  
validators to use in a message catalog.

That would entail a new ValidationConstraintGenerator, except...  
there's no simple way for a ValidationConstraintGenerator  
implementation to gain access to the message catalog for the page or  
component that holds the component for which the constraints should be  
generated.  The behavior I described above is handled at a level  
outside of the constraint generator.  Still... if you add an issue,  
I'll grab it and explore options.

Robert

On May 4, 2009, at 5/411:37 AM , mraible wrote:

>
> Do you have more information on #2? I'm not familiar with Tapestry's  
> property
> catalogs.
>
> Thanks,
>
> Matt
>
>
> Robert Zeigler wrote:
>>
>> There are a variety of things you can do.
>> You can:
>>    1) Put validation annotations on the bean properties that tapestry
>> will pick up
>>    2) Put validation information in the property catalogs that
>> tapestry will pick up
>>    3) Write and contribute your own constraint generator.  For
>> example, in the tapestry5-cayenne integration module, there is a
>> CayenneConstraintGenerator that builds constraints based on metadata
>> available from the cayenne mapping.
>>
>> For AppFuse, I would recommend #2 because it's non-intrusive (nothing
>> in the POJO) and it allows you to use the BeanEditForm, and it allows
>> you to easily modify (w/out compilation) the validation constraints.
>>
>> Cheers,
>>
>> Robert
>>
>> On May 4, 2009, at 5/410:26 AM , mraible wrote:
>>
>>>
>>> Thanks for the pointer. I guess for something like AppFuse, using  
>>> the
>>> BeanEditForm (esp. with code generation) is probably not a good
>>> idea. I'll
>>> change things to generate the individual field elements so users can
>>> more
>>> easily modify the generated template.
>>>
>>> Matt
>>>
>>>
>>> Ulrich Stärk wrote:
>>>>
>>>> I don't exactly get what you mean. You can validate for example
>>>> textfield
>>>> by passing a validator to
>>>> the validate parameter of some of the components. For example
>>>> <t:textfield
>>>> value="someProperty"
>>>> validate="required /> would make sure that someProperty actually
>>>> has a
>>>> value. See
>>>> http://tapestry.apache.org/tapestry5.1/guide/validation.html
>>>>
>>>> Uli
>>>>
>>>> mraible schrieb:
>>>>> Is it possible to do validation declaratively, or rather - only at
>>>>> the
>>>>> web
>>>>> tier? AFAIK, I can only do validation with 1) annotations on the
>>>>> model
>>>>> object or 2) manually with if (blank) logic in my Page.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Matt
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>>
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/Tapestry-5-Validation-tp23358011p23370724.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Tapestry-5-Validation-tp23358011p23371981.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: Tapestry 5 Validation

Posted by mraible <ma...@raibledesigns.com>.
Do you have more information on #2? I'm not familiar with Tapestry's property
catalogs.

Thanks,

Matt


Robert Zeigler wrote:
> 
> There are a variety of things you can do.
> You can:
>     1) Put validation annotations on the bean properties that tapestry  
> will pick up
>     2) Put validation information in the property catalogs that  
> tapestry will pick up
>     3) Write and contribute your own constraint generator.  For  
> example, in the tapestry5-cayenne integration module, there is a  
> CayenneConstraintGenerator that builds constraints based on metadata  
> available from the cayenne mapping.
> 
> For AppFuse, I would recommend #2 because it's non-intrusive (nothing  
> in the POJO) and it allows you to use the BeanEditForm, and it allows  
> you to easily modify (w/out compilation) the validation constraints.
> 
> Cheers,
> 
> Robert
> 
> On May 4, 2009, at 5/410:26 AM , mraible wrote:
> 
>>
>> Thanks for the pointer. I guess for something like AppFuse, using the
>> BeanEditForm (esp. with code generation) is probably not a good  
>> idea. I'll
>> change things to generate the individual field elements so users can  
>> more
>> easily modify the generated template.
>>
>> Matt
>>
>>
>> Ulrich Stärk wrote:
>>>
>>> I don't exactly get what you mean. You can validate for example  
>>> textfield
>>> by passing a validator to
>>> the validate parameter of some of the components. For example  
>>> <t:textfield
>>> value="someProperty"
>>> validate="required /> would make sure that someProperty actually  
>>> has a
>>> value. See
>>> http://tapestry.apache.org/tapestry5.1/guide/validation.html
>>>
>>> Uli
>>>
>>> mraible schrieb:
>>>> Is it possible to do validation declaratively, or rather - only at  
>>>> the
>>>> web
>>>> tier? AFAIK, I can only do validation with 1) annotations on the  
>>>> model
>>>> object or 2) manually with if (blank) logic in my Page.
>>>>
>>>> Thanks,
>>>>
>>>> Matt
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/Tapestry-5-Validation-tp23358011p23370724.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tapestry-5-Validation-tp23358011p23371981.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry 5 Validation

Posted by Robert Zeigler <ro...@scazdl.org>.
There are a variety of things you can do.
You can:
    1) Put validation annotations on the bean properties that tapestry  
will pick up
    2) Put validation information in the property catalogs that  
tapestry will pick up
    3) Write and contribute your own constraint generator.  For  
example, in the tapestry5-cayenne integration module, there is a  
CayenneConstraintGenerator that builds constraints based on metadata  
available from the cayenne mapping.

For AppFuse, I would recommend #2 because it's non-intrusive (nothing  
in the POJO) and it allows you to use the BeanEditForm, and it allows  
you to easily modify (w/out compilation) the validation constraints.

Cheers,

Robert

On May 4, 2009, at 5/410:26 AM , mraible wrote:

>
> Thanks for the pointer. I guess for something like AppFuse, using the
> BeanEditForm (esp. with code generation) is probably not a good  
> idea. I'll
> change things to generate the individual field elements so users can  
> more
> easily modify the generated template.
>
> Matt
>
>
> Ulrich Stärk wrote:
>>
>> I don't exactly get what you mean. You can validate for example  
>> textfield
>> by passing a validator to
>> the validate parameter of some of the components. For example  
>> <t:textfield
>> value="someProperty"
>> validate="required /> would make sure that someProperty actually  
>> has a
>> value. See
>> http://tapestry.apache.org/tapestry5.1/guide/validation.html
>>
>> Uli
>>
>> mraible schrieb:
>>> Is it possible to do validation declaratively, or rather - only at  
>>> the
>>> web
>>> tier? AFAIK, I can only do validation with 1) annotations on the  
>>> model
>>> object or 2) manually with if (blank) logic in my Page.
>>>
>>> Thanks,
>>>
>>> Matt
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Tapestry-5-Validation-tp23358011p23370724.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: Tapestry 5 Validation

Posted by mraible <ma...@raibledesigns.com>.
Thanks for the pointer. I guess for something like AppFuse, using the
BeanEditForm (esp. with code generation) is probably not a good idea. I'll
change things to generate the individual field elements so users can more
easily modify the generated template.

Matt


Ulrich Stärk wrote:
> 
> I don't exactly get what you mean. You can validate for example textfield
> by passing a validator to 
> the validate parameter of some of the components. For example <t:textfield
> value="someProperty" 
> validate="required /> would make sure that someProperty actually has a
> value. See 
> http://tapestry.apache.org/tapestry5.1/guide/validation.html
> 
> Uli
> 
> mraible schrieb:
>> Is it possible to do validation declaratively, or rather - only at the
>> web
>> tier? AFAIK, I can only do validation with 1) annotations on the model
>> object or 2) manually with if (blank) logic in my Page. 
>> 
>> Thanks,
>> 
>> Matt
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tapestry-5-Validation-tp23358011p23370724.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry 5 Validation

Posted by Ulrich Stärk <ul...@spielviel.de>.
I don't exactly get what you mean. You can validate for example textfield by passing a validator to 
the validate parameter of some of the components. For example <t:textfield value="someProperty" 
validate="required /> would make sure that someProperty actually has a value. See 
http://tapestry.apache.org/tapestry5.1/guide/validation.html

Uli

mraible schrieb:
> Is it possible to do validation declaratively, or rather - only at the web
> tier? AFAIK, I can only do validation with 1) annotations on the model
> object or 2) manually with if (blank) logic in my Page. 
> 
> Thanks,
> 
> Matt


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