I found the problem with my form validation not validating an integer field correctly. The problem was in the <form-property> for the form field. I had declared it as "java.lang.Integer", but when I changed it to "java.lang.String" it worked perfect.
In the struts-config.xml it should be:
<form-bean name="bookForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="title" type="java.lang.String" />
<form-property name="numpages" type="java.lang.String" />
</form-bean>NOT:
<form-bean name="bookForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="title" type="java.lang.String" />
<form-property name="numpages" type="java.lang.Integer" />
</form-bean>- vic
Victor J. Soares wrote:
Hello,
I am learning how to use the DynaValidatorForm and Validtor, but I have run into a problem I can't figure out:
One of the fields in the form is of type "Integer". The validation rules I set up check to see if (1) the a value has been given (required) (2) the value given is an integer.
I submit the form, but the validation doesn't catch either of those cases and return the form populated with "0".
Can somebody clue me in on Integer validation?
thanks, - vic
Below are the snippets from the pertinent configs:
struts-config.xml------------- <form-bean name="bookForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="title" type="java.lang.String" /> <form-property name="numpages" type="java.lang.Integer" /> </form-bean> ---------------------------
validation.xml---------------
<form name="bookForm">
<field property="title" depends="minlength,maxlength">
<arg0 key="prompt.title"/>
<arg1 key="${var:minlength}" name="minlength" resource="false"/>
<arg2 key="${var:maxlength}" name="maxlength"
resource="false"/>
<var>
<var-name>maxlength</var-name>
<var-value>16</var-value>
</var>
<var>
<var-name>minlength</var-name>
<var-value>3</var-value>
</var>
</field>
<field property="numpages" depends="required,integer"> <arg0 key="prompt.pages"/> </field>
</form> -----------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

