Hi,
 
I'm trying to add some validation to my fstruts 2 form but it won't
work.
If I enter for example value '6' in my weight textfield and press 'add',
the debugger comes in the method 'addProduct', finishes and returns to
products.jsp.
There is no message shown as defined in the validation xml.
Does someone see what goes wrong?
 
 
In products.jsp I have the following code:
...
<s:head/>
</head>
...
<s:fielderror /> 
<s:actionerror />
<s:form action="addProduct" method="post" validate="true"
namespace="/service">
weight: <s:textfield name="weight" />
<s:submit value="addProduct" align="center" cssClass="button" />
</s:form> 
...

In struts.xml I have:

<action name="addProduct" class="be.shop.service.ProductActions"
method="addProduct" >
<result name="input">/products.jsp</result>
<result>/products.jsp</result>
<result name="error">/products.jsp</result>
</action>

In ProductActions.java i have:

public String addProduct(){
return SUCCESS;
}

In ProductActions-addProduct-validation.xml I have:

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator
1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd";> 
<validators> 
<field name="weight"> 
<field-validator type="double"> 
<param name="min">0</param> 
<param name="max">3</param> 
<message>Weight has to be numeric and can't be less than 0.</message> 
</field-validator> 
</field>  
</validators> 

thx!

Sandy

Reply via email to