Hi,

Quite a few days ago I posted this question and nobody answered. I
guess this is something we cannot currently do right now with v2.0.9?

Should I post it in JIRA as an improvement for future versions?

Does even anybody think it would be useful to have validation defined
on multiple similar form fields?

Gabriel

2007/9/7, Gabriel Belingueres <[EMAIL PROTECTED]>:
> 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