On 29 January 2010 17:47, Thiago H. de Paula Figueiredo <thiag...@gmail.com>wrote:
> Inject FieldValidatorSource and use its FieldValidator > createValidators(Field field, String specification) method to generate a > FieldValidator. Then create a FieldValidator getValidator() method using > createValidators() and add t:validate="prop:validator" to your TextField. > > Thanks, this got me in the right direction. I can already create a fieldValidator successfully. The thing is that I found to create it I need to have a @InjectComponent("textFieldName") and the only way I know to do this is inside a page Class. I resolved this adding a fieldValidator to each of my "Field" object when I render the page. My code is like this: <t:loop source="fields" value="currentField" t:formstate="ITERATION"> <t:if test="currentField.visible"> <tr> <td><label for="currentField.fieldName">${currentField.fieldName}:</label> </td> <td><input type="text" t:type="TextField" t:id="field" t:value="currentField.fieldValue" t:validate="prop:currentField.fieldValidator"/></td> </tr> </t:if> </t:loop> This works fine except when using InjectComponent I need to give it a fieldId and since I use a loop I don't really know what the field ID's are (except that they are ID_0, ID_1, etc..) . This is not critical but in a presentation point of view it points the errors to the wrong field. Is there any way to bind a fieldValidator to a field without using InjectComponent in the page class? Thanks in advance, Nuno Ferreira