I know, it's only called during (before) rendering.

Anyway, after inspecting the stack trace, I found out that Tapestry is
re-evaluating the /validate/ parameter of a TextField upon form submission.
More specifically, when the form is submitted, the TextField is asked to
validate itself and to this end it attempts to re-evaluate its validate
parameter.
Clearly, this is undesired behavior and it would be nice to have this
disabled in later versions of Tapestry (assuming that in most use-cases,
fields on a page require the exact same validators at validate-time as those
that were passed to them at render-time).

I did manage to find a solution though: rather than using a render variable,
mycomponent takes an extra parameter, namely a persisted property. The
property is set while mycomponent is rendered, and because it's persisted,
it remains bound when the form is submitted.

The result = a component that decides on the validators of a field it
contains (at render-time):

<t:mycomponent paramForField="component:fieldID"
paramForValidatorProperty="validators" >
  <t:textfield t:id="fieldID" t:validate="prop:validators" />
</t:mycomponent>

(Java declaration for the property is: @Persist @Property FieldValidator
validators;)

Thanks for all your help!

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Is-it-possible-to-add-Field-validators-at-render-time-tp5682920p5685839.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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

Reply via email to