You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by mem <me...@gmail.com> on 2012/08/01 09:21:57 UTC

Re: Example of overriding the default ValidationDecorator

Hello,

hope this Thread is still alive.
I've used a similar approach to figure out if the label is attached to a
field which renders a required field. The whole thing is a bit complex as
we're using JSR303 annotations on the DTO so i've to get the parameter of
the textField and then evaluate the string. Using reflection i'm checking if
the attribute of the DTO has a NotNull annotation and depending on that i'm
appending a CSS class which then renders an asterisk.
Funny thing is that this doesn't work when i'm switching on the Tapestry
Production Mode. When debugging i found out that all fields in my component
are null whereas they're the expected objects when not using production
mode.
I couldn't figure out why that is, does anyone have an explanation for this
behavior or any clues where/what to search for?

Thanks in advance.

Matt



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Example-of-overriding-the-default-ValidationDecorator-tp2419072p5714940.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: Example of overriding the default ValidationDecorator

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 03 Aug 2012 04:57:02 -0300, mem <me...@gmail.com>  
wrote:

> value has to parsed, probably ending up in the same situation as i'm now
> with the production mode. So i guess i'm stuck with adding the css  
> classes just manually to the fields.

Instead of implementing a ValidationDecorator, you could implement one or  
more Validators and apply them automatically to fields by contributing a  
ValidationConstraintGenerator. Look at the render() method of Validator:  
you can use it to change the generated Tapestry DOM.

-- 
Thiago H. de Paula Figueiredo

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


Re: Example of overriding the default ValidationDecorator

Posted by mem <me...@gmail.com>.
That's what i already thought of too, i was just hoping to be wrong.
I tried all kinds of different approaches, a mixin can't really work as it
should be applied to labels automatically and not manually adding a mixin.
Using a worker i would get there but there're issues with the dynamically
created conduits and it gets really messy with reflection as the parameter
value has to parsed, probably ending up in the same situation as i'm now
with the production mode. So i guess i'm stuck with adding the css classes
just manually to the fields.

Anyways, thanks for the answer.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Example-of-overriding-the-default-ValidationDecorator-tp2419072p5715029.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: Example of overriding the default ValidationDecorator

Posted by Josh Canfield <jo...@gmail.com>.
You are probably running into the fact that Tapestry rewrites your
page/component classes so that there is only one instance of the class used
across all requests. To do this all of the property accesses are
intercepted and replaced with ThreadLocal values. When you are in
development mode tapestry shadows the values in the actual class itself so
that you can see them in the debugger.

Check out this fixed issue for more details
https://issues.apache.org/jira/browse/TAP5-1208

Have you considered using a Mixin?
http://tapestry.apache.org/component-mixins.html

Or possibly you could write your own class transformer :
http://tawus.wordpress.com/2011/04/21/plastic-property/

Josh

On Aug 1, 2012 12:22 AM, "mem" <me...@gmail.com> wrote:

> Hello,
>
> hope this Thread is still alive.
> I've used a similar approach to figure out if the label is attached to a
> field which renders a required field. The whole thing is a bit complex as
> we're using JSR303 annotations on the DTO so i've to get the parameter of
> the textField and then evaluate the string. Using reflection i'm checking
> if
> the attribute of the DTO has a NotNull annotation and depending on that i'm
> appending a CSS class which then renders an asterisk.
> Funny thing is that this doesn't work when i'm switching on the Tapestry
> Production Mode. When debugging i found out that all fields in my component
> are null whereas they're the expected objects when not using production
> mode.
> I couldn't figure out why that is, does anyone have an explanation for this
> behavior or any clues where/what to search for?
>
> Thanks in advance.
>
> Matt
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Example-of-overriding-the-default-ValidationDecorator-tp2419072p5714940.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
>
>