You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by carmi_cd <ca...@yahoo.com> on 2008/02/18 06:06:51 UTC

[S2] Validation

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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] Validation

Posted by carmi_cd <ca...@yahoo.com>.
i was able to identify the problem it was only in IE,I put the
showLoadingText="false"
to my save button then it validates correctly before it wasn't able to get
the form values in IE.

still thanks newton.date.  :-)



newton.dave wrote:
> 
> --- carmi_cd <ca...@yahoo.com> wrote:
>> 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"/>
> 
> You're validating on "lastName" etc; do you have getters and setters for
> "lastName" and so on, or are you assuming there's a getEdituser() and all
> the
> values are being set on the edituser bean?
> 
> Dave
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Validation-tp15539111p15557767.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] Validation

Posted by Dave Newton <ne...@yahoo.com>.
--- carmi_cd <ca...@yahoo.com> wrote:
> 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"/>

You're validating on "lastName" etc; do you have getters and setters for
"lastName" and so on, or are you assuming there's a getEdituser() and all the
values are being set on the edituser bean?

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org