You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wei Xu <ta...@hotmail.com> on 2007/06/13 10:58:46 UTC
[S2] Multiple problem
First, you can look through next jsp codes:
<s:iterator status="stat" value="destObjects">
<tr>
<s:iterator value="visibleColumns">
<td>
<s:property value="destObjects[%{#stat.index}].%{fieldDefName}" />
</td>
</s:iterator>
</tr>
</s:iterator>
Variable "destObejcts" is a <LIST> type which contains a serial of objects
named "destObject".
Variable "visibleColumns" is also a LIST of objects named "visibleColumn",
and "fieldDefName" is a property of "visibleColumn".
And thus value of expression "visibleColumn.fieldDefName" will be a property
name of object "destObject".
Above relationship between two objects sounds a bit boring. As a trouble, I
failed to get the correct values of these dynamic fields of "destObejct",
and I had tried in many ways, and next Struts2 expressions ALL could not
work:
<s:property value="destObjects[%{#stat.index}].%{fieldDefName}" />
<s:property value="%{destObjects[#stat.index].%{fieldDefName}}" />
<s:property value="%{fieldDefName}" />
Is there anyone could help me? Thanks.
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Multiple problem
Posted by Laurie Harper <la...@holoweb.net>.
Please keep related messages within the same thread and try to avoid
re-posting a question without the context of any prior discussion. See
below for another suggestion:
Wei Xu wrote:
> First, you can look through next jsp codes:
>
> <s:iterator status="stat" value="destObjects">
> <tr>
> <s:iterator value="visibleColumns">
> <td>
> <s:property value="destObjects[%{#stat.index}].%{fieldDefName}" />
> </td>
> </s:iterator>
> </tr>
> </s:iterator>
Why do the indexing into destObjects manually when s:iterator is already
doing it for you? How about something like this:
<s:iterator id="do" value="destObjects">
<tr>
<s:iterator value="visibleColumns">
<td>
<s:property value="%{#do[fieldDefName]}"/>
</td>
</s:iterator>
</tr>
</s:iterator>
or, being a little more explicit if you prefer:
<s:iterator id="do" value="destObjects">
<tr>
<s:iterator id="vc" value="visibleColumns">
<td>
<s:property value="%{#do[#vc.fieldDefName]}"/>
</td>
</s:iterator>
</tr>
</s:iterator>
> ALL could not work:
>
> <s:property value="destObjects[%{#stat.index}].%{fieldDefName}" />
> <s:property value="%{destObjects[#stat.index].%{fieldDefName}}" />
> <s:property value="%{fieldDefName}" />
The first two don't look like valid OGNL expressions to me; I don't know
OGNL very well, but I wouldn't expect it to support nested expressions
(%{...%{...}...}).
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org