Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Struts Validation not being called at all

Status
Not open for further replies.

piampri

Programmer
Apr 5, 2006
13
0
0
CA
Hello,

I am trying to validate two fields in a JSP using the Struts Validator plugin. When I hit the "Submit" button nothing happens. I get the feeling that the action is being processed, but because the fields are empty, an error should pop up.

This is my JSP :

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>

<html>
<body>
<html:errors/>
<html:form action="test.do">
<table>
<tr>
<td>Name:</td>
<td><html:text property="name"/></td>
</tr>
<tr>
<td>Age:</td>
<td><html:text property="age"/></td>
</tr>
<tr><td><html:submit/></td></tr>
</table>
</html:form>
</body>

</html>

This is my validation.xml file :

form-validation>
<global/>
<formset>
<constant>
<constant-name>dateFormat</constant-name>
<constant-value>yyyy-MM-dd</constant-value>
</constant>
<form name="datePPOFilterForm">
<field property="fromdate" depends="required">
<arg0 key="label.from"/>
</field>
<field property="todate" depends="required">
<arg0 key="label.to"/>
</field>
</form>
<form name="testForm">
<field property="name" depends="required">
<arg0 key="label.from"/>
</field>
<field property="age" depends="required">
<arg0 key="label.to"/>
</field>
</form>
</formset>
</form-validation>

This is my struts-config file fragment(s)

NB. I have included the Validator Plug-in in the struts-config file.

I've extended ValidatorForm and not Action Form for the Form bean.

I've included the relevant error keys from the validation-rules.xml file into my properties file.

When I hit the button(submit) nothing happens. No messages whatsoever
 
Did you solve this ?
using struts 1.2 ?

I cannot se how your bean looks like,
difficult to re-create the problem.

regards, i
 
Does the action definition in your struts-config.xml file have "validate=true"?

e.g.
Code:
<action path="/test"
        name="someForm"
        [red]validate="true"[/red]
        ...
>
...
</action>

-G
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top