Hi, Well, passing a parameter to the field to configure its validator is exactly what I'm trying to do. The fields I need already take a parameter for this purpose (i.e., t:validate), so it doesn't seem useful to extend them to use Environmentals instead.
The issue here is that t:validate works well if you pass static text, for instance: "required, regexp", but, if you want to dynamically decide on the validators (i.e., by passing a property instead of a validate string), the property requires the type *FieldValidator*. Now it is possible to instantiate FieldValidators at render-time, but to this end, you need a reference to the *Field* you want to pass the validator to. For instance, if you're just /in a page/, this (thanks to Lance) works: Java Page { @Inject Field textField; @Inject FieldValidatorSource fieldValidatorSource; public FieldValidator getValidators() { StringBuilder validators = new StringBuilder("a,b,c"); if (required) { validators.append(",required"); } return fieldValidatorSource.createValidators(textField, validators.toString()); } } Corresponding Page TML { <t:textfield t:id="textField" validate="prop:validators" /> } Now I don't want to provide the property from within a page, but /from within a custom component/ instead. More specifically, I'd like to do this: Page TML { <t:mycomponent> <t:textfield t:id="textField" validate="var:validators" /> </t:mycomponent> } The component knows what validators are required, and I can bind the validators render variable at render-time (i.e., exactly when I need it) so that's ok, but, in order to bind it I need to create the FieldValidator, and for the latter I need a reference to the field that's in the component's body. Therefore my question: how can I obtain a reference to this field (given its ID), in the component, preferably in the setupRender phase (as I think the validators variable should be bound at that time)? PS: Things would be way easier if I could only bind a String with validators to the render variable, and let Tapestry create the FieldValidators itself, but that doesn't seem to work, cfr. earlier in the conversation (accessible at http://tapestry.1045711.n5.nabble.com/Is-it-possible-to-add-Field-validators-at-render-time-td5682920.html). Wouter -- View this message in context: http://tapestry.1045711.n5.nabble.com/Is-it-possible-to-add-Field-validators-at-render-time-tp5682920p5684972.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