Hi I have an application in Struts 2, my problem is when i try to submit the
form even if there are
values in the form input box it stills give validation message to the user
to enter values for the
required fields.
here is my form fields.
<s:textfield name="employeeId" label="Employee ID" labelposition="left"
value="%{edituser.empId}" size="10"/>
<s:textfield name="lastname" label="Lastname" labelposition="left"
value="%{edituser.lastName}" size="30"/>
<s:textfield name="firstname" label="First Name" labelposition="left"
value="%{edituser.firstName}" size="30"/>
<s:textfield name="middlename" label="Middle Name" labelposition="left"
value="%{edituser.middleName}" size="30"/>
<s:textfield name="position" label="Position" labelposition="left"
value="%{edituser.position}" size="40"/>
here is my UserMgt-save-validation.xml:
<!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="employeeId">
<field-validator type="requiredstring">
true
<message>Employee ID is required.</message>
</field-validator>
</field>
<field name="lastname">
<field-validator type="requiredstring">
true
<message>Lastname is required.</message>
</field-validator>
</field>
<field name="firstname">
<field-validator type="requiredstring">
true
<message>First Name is required.</message>
</field-validator>
</field>
<field name="username">
<field-validator type="requiredstring">
true
<message key="requiredstring"/>
</field-validator>
</field>
<field name="password">
<field-validator type="requiredstring">
true
<message key="requiredstring"/>
</field-validator>
</field>
<validator type="expression" >
password.equals(password2)
<message>Password confirmation did not match.</message>
</validator>
</validators>
I also implement prepare interceptors in my action class UserMgt.class
here is the prepare code
public void prepare() throws Exception {
if (userid != null ){
UserBean userBean = new UserBean();
setEdituser(userBean.findUser(userid));
}
ModuleBean moduleBean=new ModuleBean();
setModules(moduleBean.getAllModule());
}
please help me. Thanks in advance for your help.
--
View this message in context:
http://www.nabble.com/-S2--Validation-tp15539111p15539111.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]