You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by LLTYK <LL...@mailinator.com> on 2010/09/28 14:35:46 UTC

Is there a way to automatically generate validation constraints on standalone fields?

I'd like for something like <t:textfield value="bean.textvalue" /> to somehow
know what validators (length,etc) to use. 

There seems to be a way to do this with annotations on the bean's fields,
but I am using Cayenne which stores constraint information in an xml file,
and do not want to duplicate this by adding annotations. 

So my ValidationConstraintGenerator would need to know what bean class and
which property to look up things from the xml file. In the t5-cayenne
project the ValidationConstraintGenerator pulls the BeanEditContext and
PropertyEditContext from the Environment, and gets the necessary information
from those. These are only available inside a BeanEditor though.

Is there some other method for generating validators automatically? The
internal AccessableObjectAnnotationProvider looks interesting, as it can
access the property and bean class, and so would be able to mock up an
@Validate annotation. It doesn't look like it's meant to be overridden
though.
-- 
View this message in context: http://tapestry-users.832.n2.nabble.com/Is-there-a-way-to-automatically-generate-validation-constraints-on-standalone-fields-tp5579233p5579233.html
Sent from the Tapestry Users 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: Is there a way to automatically generate validation constraints on standalone fields?

Posted by Robert Zeigler <ro...@scazdl.org>.
Whoops, sorry, read your original e-mail too fast; I see you've already looked at t5-cayenne, and you're interested in standalone fields...

I'm not sure there's a way to do what you want, short of doing something like:
<t:beaneditor object="obj" include="oneValue"/>

Which would bootstrap everything for you, and still get you your one field (albeit wrapped in the bean edit div, etc.).

Alternatively, there's no real reason you can't push the requisite information (BeanEditContext, PropertyEditContext) yourself, right?
But at that point, if you're editing a single value in a single field, why not specify the constraints manually?

Might be able to offer better suggestions if I had a clearer idea of your use-case...

Robert

On Sep 28, 2010, at 9/2812:58 PM , Robert Zeigler wrote:

> I implemented a constraint generator for cayenne mapping files in the t5cayenne project awhile back.
> http://code.google.com/p/tapestry5-cayenne/source/browse/trunk/tapestry5-cayenne-core/src/main/java/com/googlecode/tapestry5cayenne/services/CayenneConstraintGenerator.java
> 
> Current trunk is compatible with 5.2; need to do another release of the project.
> 
> Cheers,
> 
> Robert
> 
> On Sep 28, 2010, at 9/287:35 AM , LLTYK wrote:
> 
>> 
>> I'd like for something like <t:textfield value="bean.textvalue" /> to somehow
>> know what validators (length,etc) to use. 
>> 
>> There seems to be a way to do this with annotations on the bean's fields,
>> but I am using Cayenne which stores constraint information in an xml file,
>> and do not want to duplicate this by adding annotations. 
>> 
>> So my ValidationConstraintGenerator would need to know what bean class and
>> which property to look up things from the xml file. In the t5-cayenne
>> project the ValidationConstraintGenerator pulls the BeanEditContext and
>> PropertyEditContext from the Environment, and gets the necessary information
>> from those. These are only available inside a BeanEditor though.
>> 
>> Is there some other method for generating validators automatically? The
>> internal AccessableObjectAnnotationProvider looks interesting, as it can
>> access the property and bean class, and so would be able to mock up an
>> @Validate annotation. It doesn't look like it's meant to be overridden
>> though.
>> -- 
>> View this message in context: http://tapestry-users.832.n2.nabble.com/Is-there-a-way-to-automatically-generate-validation-constraints-on-standalone-fields-tp5579233p5579233.html
>> Sent from the Tapestry Users 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


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


Re: Is there a way to automatically generate validation constraints on standalone fields?

Posted by Robert Zeigler <ro...@scazdl.org>.
I implemented a constraint generator for cayenne mapping files in the t5cayenne project awhile back.
http://code.google.com/p/tapestry5-cayenne/source/browse/trunk/tapestry5-cayenne-core/src/main/java/com/googlecode/tapestry5cayenne/services/CayenneConstraintGenerator.java

Current trunk is compatible with 5.2; need to do another release of the project.

Cheers,

Robert

On Sep 28, 2010, at 9/287:35 AM , LLTYK wrote:

> 
> I'd like for something like <t:textfield value="bean.textvalue" /> to somehow
> know what validators (length,etc) to use. 
> 
> There seems to be a way to do this with annotations on the bean's fields,
> but I am using Cayenne which stores constraint information in an xml file,
> and do not want to duplicate this by adding annotations. 
> 
> So my ValidationConstraintGenerator would need to know what bean class and
> which property to look up things from the xml file. In the t5-cayenne
> project the ValidationConstraintGenerator pulls the BeanEditContext and
> PropertyEditContext from the Environment, and gets the necessary information
> from those. These are only available inside a BeanEditor though.
> 
> Is there some other method for generating validators automatically? The
> internal AccessableObjectAnnotationProvider looks interesting, as it can
> access the property and bean class, and so would be able to mock up an
> @Validate annotation. It doesn't look like it's meant to be overridden
> though.
> -- 
> View this message in context: http://tapestry-users.832.n2.nabble.com/Is-there-a-way-to-automatically-generate-validation-constraints-on-standalone-fields-tp5579233p5579233.html
> Sent from the Tapestry Users 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