Hi Everyone,

I have a form which is getting generated dynamically based on some values in
database. I want to add validation for a text box based on some condition.

I tried doing some thing like this

<t:textfield t:validate="*${validator}*"></t:textfield>

and added the below method in respective java file

public String getValidator(){
   if(test for validation condition){
       return "required";
   }else{
       return "";
   }
}

I am getting some exception saying *"Could not find a coercion from type
java.lang.String to type org.apache.tapestry5.FieldValidator."*

>From the exception, I understood that it is expecting FieldValidator, but I
am not getting how to initalize a *"required" FieldValidator* and return it.

I have one more fix (which I didn't like)
<t:if test="test for validation">
      <t:textfield t:validate="*${validator}*"></t:textfield>
      <t:parameter name="else">
               <t:textfield></t:textfield>
      </t:parameter>
</t:if>


Please Let me know, if there is a way to initalize a FieldValidator.

-- 
Thanks & Regards
Jagadesh

Reply via email to