Hi

I'm fairly new to Struts, but I am involved in a small web project that uses
struts. Another person in the group has been responsible for the presentation
part of the project, with Struts in the center. But he got stuck on a problem
with validation, and at the moment he relly doesn't have the time now to try to
fix it.
And since I wanted to learn Struts, I said I could look into it.

The problem is that we can't get validation to work for jsp-pages that uses
indexedListProperty. We have written no ActionForm classes, but uses a single
DynaValidatorActionForm. We use Struts 1.1.

The web page as such first start with a form where the user can enter his name,
email and swedish social security number. Both the javascript and the server
validation works here, but there is no indexedListProperty used here.

The next to form pages, both uses indexedListProperty, and none of the
validation works here. When I look at the generated html-code, I see things
like this:

    function required () {
    }

    function IntegerValidations () {
    }

Why are these functions (or javascript-objects, as I have understood it) empty?
And why doesn't server validation work?

Here is some of the code:

The form bean in struts-config.xml:
    <form-bean name="applicationForm"
type="org.apache.struts.validator.DynaValidatorActionForm">
      <form-property name="jobSeeker" type="recruit.business.model.JobSeeker" />
      <form-property name="profile" type="recruit.business.model.Profile[]"
size="1"/>
      <form-property name="availability"
type="recruit.business.model.Availability[]" size="1"/>
    </form-bean>

Some actions:
    <action
      attribute="applicationForm"
      input="/index.jsp?body=jobSeeker.jsp"
      name="applicationForm"
      path="/jobSeeker"
      validate="true"
      type="recruit.presentation.controller.ApplicationAction">
      <forward name="next" path="/index.jsp?body=profile.jsp" />
    </action>

    <action
      attribute="applicationForm"
      input="/index.jsp?body=profile.jsp"
      name="applicationForm"
      path="/profile"
      validate="true"
      type="recruit.presentation.controller.ApplicationAction">
      <forward name="next" path="/index.jsp?body=availability.jsp" />
      <forward name="next_profile" path="/index.jsp?body=profile.jsp" />
      <forward name="prev_profile" path="/index.jsp?body=profile.jsp" />
      <forward name="prev" path="/index.jsp?body=jobSeeker.jsp" />
    </action>

Some validation in validation.xml
<!-- JobSeeker -->
     <form name="/jobSeeker">
        <field property="jobSeeker.firstName"
           depends="required">
           <arg0 key="jobSeeker.firstname"/>
          </field>
        <field property="jobSeeker.surName"
           depends="required">
           <arg0 key="jobSeeker.surname"/>
          </field>
        <field property="jobSeeker.ssn"
           depends="required">
           <arg0 key="jobSeeker.ssn"/>
          </field>
        <field property="jobSeeker.ssn"
           depends="long">
           <arg0 key="jobSeeker.ssn"/>
          </field>
        <field property="jobSeeker.ssn"
           depends="minlength">
           <arg0 key="jobSeeker.ssn"/>
           <arg1 name="minlength" key="${var:minlength}" resource="false"/>
           <var><var-name>minlength</var-name><var-value>10</var-value></var>
          </field>
        <field property="jobSeeker.ssn"
           depends="maxlength">
           <arg0 key="jobSeeker.ssn"/>
           <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
           <var><var-name>maxlength</var-name><var-value>10</var-value></var>
          </field>
        <field property="jobSeeker.email"
           depends="required">
           <arg0 key="jobSeeker.email"/>
        </field>
        <field property="jobSeeker.email"
           depends="email">
           <arg0 key="jobSeeker.email"/>
        </field>
      </form>

<!-- Profile -->
      <form name="/profile">
        <field property="monthsOfExperience"
            indexedListProperty="profile"
            depends="required">
            <arg0 key="profile.monthsOfExperience" />
        </field>
        <field property="monthsOfExperience"
            indexedListProperty="profile"
            depends="integer">
            <arg0 key="profile.monthsOfExperience" />
        </field>
        <field property="competence.competence_id"
            indexedListProperty="profile"
            depends="required">
            <arg0 key="profile.competence" />
        </field>
      </form>

I hope if this is enough to find what is wrong with our configuration. Can
someone see what we are doing wrong? Or is this some bug in Struts 1.1?

Regards
/Jimi

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

Reply via email to