Hi,

Looking at the example of making a form using an indexed list in the
following URL: http://struts.apache.org/2.0.9/docs/type-conversion.html

Take for example a form with the following fields:

    <s:iterator id="contacto" value="referidos" status="status">
      <tr>
        <td>
          <del>
            <s:hidden name="referidos[%{#status.index}].referidoId" />
          </del>
          <s:fielderror ><s:param
value="referidos[%{#status.index}].email" /></s:fielderror>
          <s:textfield name="referidos[%{#status.index}].email"
           required="true" tooltip="Ingrese el email" />
        </td>
        <td>
          <s:fielderror
><s:param>referidos[%{#status.index}].nombre</s:param></s:fielderror>
          <s:textfield name="referidos[%{#status.index}].nombre"
           tooltip="Ingrese el nombre" />
        </td>
        <td>
          <s:fielderror
><s:param>referidos[%{#status.index}].apellido</s:param></s:fielderror>
          <s:textfield name="referidos[%{#status.index}].apellido"
           tooltip="Ingrese el apellido" />
        </td>
        <td>
          <s:submit value="Borrar"
           onclick="this.form.action =
'invitar_delete.action?indexToDelete=%{#status.index}';" />
        </td>
      </tr>
    </s:iterator>


The question is HOW to write a validation.xml file for validating this form.

I tried using a VisitorValidator, where I validate the bean fields,
but I couldn't find yet a way to tell the validator to iterate the
validator on ALL beans in the list.

The following validator does not work (since the validator doesn't
know the status variable of the iterator):
<validators>
  <field name="referidos[%{#status.index}]">
    <field-validator type="visitor">
      <message>Referido:</message>
    </field-validator>
  </field>
</validators>

The following works, but is NOT dynamic, since the indexes are fixed here:

<validators>
  <field name="referidos[0]">
    <field-validator type="visitor">
      <message>Referido:</message>
    </field-validator>
  </field>
  <field name="referidos[1]">
    <field-validator type="visitor">
      <message>Referido:</message>
    </field-validator>
  </field>
</validators>

What I need is some form of telling the validation framework that it
must iterate on all elements of the list.

Any ideas? It is solvable using only validation.xml files? or must I
use the validate() method here?

Regards,
Gabriel

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

Reply via email to