Hi,

Could you try to specify  validate="true"> in the struts-config.xml instead?

Yanhui Yu






-----Original Message-----
From: Oliver Reflé [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 20, 2002 3:22 AM
To: Struts-User
Subject: form looses valuse when validation maps back


Hello All,
i have for me a real strange problem. When i validate my form and there are
missing
fields then it is mapped back to the input page. All the error messages are
shown correctly.
The only thing is that my form is empty and the user has to reenter all
values,  which is
really annoying.

This is my entry in the struts-config.xml

    <action path="/admin/createCompany"

type="com.transwide.services.uma.web.action.admin.CreateCompanyAction"
            name="companyForm"
            scope="session"
            input="/uma/admin/create-company-step1.jsp"
            validate="false">
      <forward name="success"
               path="/uma/admin/create-company-step2.jsp">
      </forward>
      <forward name="failure"
               path="/uma/admin/failure.jsp">
      </forward>
    </action>

The validation is done in the action class(business reason), but i tried it
also in the Form which
makes no difference. Here is part of my Action which handles the validation

        ActionErrors errors = new ActionErrors();

        try{

            CompanyForm companyForm = (CompanyForm)form;

            // some validations
            if (companyForm.getAccountName()==null ||
StringUtils.isEmpty(companyForm.getAccountName())) {
                errors.add("accountname", new
ActionError("error.accountname"));
            }
            if (companyForm.getCompanyName()==null ||
StringUtils.isEmpty(companyForm.getCompanyName())) {
                errors.add("companyname", new
ActionError("error.companyname"));
            }
            if (companyForm.getPrefix()==null ||
StringUtils.isEmpty(companyForm.getPrefix())) {
                errors.add("prefixlength", new ActionError("error.prefix"));
            } else if (companyForm.getPrefix().length() != 3) {
                errors.add("prefixlength", new
ActionError("error.prefixlength"));
            }
            if(companyForm.getCompanyTypes()==null ||
StringUtils.isEmpty(companyForm.getCompanyTypes())) {
                errors.add("companytypes", new
ActionError("error.companytypes"));
            }
            if(companyForm.getVatNumber()==null ||
StringUtils.isEmpty(companyForm.getVatNumber())) {
                errors.add("vatnumber", new ActionError("error.vatnumber"));
            }
            if (!errors.empty()) {
                saveErrors(request, errors);
                return (new ActionForward(mapping.getInput()));
            }

I can take the form data out of the session with a scriptlet and display the
values, but
struts don't fills out the form automaticly. First thing i took a look on
it, that i maybe
configured the scope of the form incorrect and when mapping back to input he
trys to generate
a new form which is only stored in the request. But there all settings seem
to be correct.

Any idea ??

oliver


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to