You are not the only one that thinks so.

There are some OGNL expression issues involved that are confusing too:

<s:iterator id="contacto" value="referidos" status="status">
  <s:fielderror>
    <s:param value="%{'referidos[' + #status.index + '].email'}"/>
  </s:fielderror>
  <s:textfield name="referidos[%{#status.index}].email" />
</s:iterator>

in the s:param:
<s:param value="referidos[%{#status.index}].email" />
won't work (the same expression as the textfield)
But s:param evaluates the expression in a different way when placing
it as a child:
<s:param>referidos[%{#status.index}].email</s:param>
but this won't work either.

Now this won't work either:
<s:param>%{'referidos[' + #status.index + '].email'}</s:param>

On top of that, you usually want to use your form with the "simple"
theme when using indexed fields because you may want them arranged in
a way different than the 2 column table "xhtml" them (this is my
current case anyway). If you are brave enough you may modify or create
a new theme for those indexed forms.

Other issues you may encounter commonly is:

a) adding a new field set (object to your collection).
b) delete a file set (object from your collection) when there is at least one.
c) Should validation occur only when submitting the form? or in each
modification? for example when adding/deleting a new field set?

Regards,
Gabriel

2007/10/10, Jake Robb <[EMAIL PROTECTED]>:
> Okay, so I figured out the right syntax for the question I posted
> yesterday (subject: List properties in Struts 2).
>
> Let's say I have a List of key-value pairs and I want to render the
> entire list to the user as a form.  In Struts 1.x, here's the JSP
> snippet:
>
>  <logic:iterate list="pairs">
>    <html:text name="pairs" property="key" indexed="true" />
>    <html:text name="pairs" property="value" indexed="true" />
>  </logic:iterate>
>
> But in S2, I have to do this:
>
>  <s:iterator value="pairs" status="status">
>    <s:textfield name="%{'pairs['+#status.index+'].name'}" />
>    <s:textfield name="%{'pairs['+#status.index+'].value'}" />
>  </s:iterator>
>
> It seems to me that this use case is common enough that the S2 method
> should be more friendly and obvious, and should not involve assembling
> an OGNL expression manually in the JSP.  It seems to me that bringing
> back Struts 1's iterator-aware field tags would be relatively
> straightforward.  It'd be extra nice if the tag simply recognized that
> the value being pulled in from an iterator automatically, so that you
> didn't even need the "indexed" attribute:
>
>  <s:iterator value="pairs" id="pair">
>    <s:textfield name="name" />
>    <s:textfield name="value" />
>  </s:iterator>
>
> How difficult would that be?  It already works to *populate* a form; I
> just can't submit back to the action and have it fill in my object.
>
> Am I the only one that thinks that the current S2 way is a huge pain?
>
> -Jake Robb
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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

Reply via email to