Well, I didn't get any responses to this, but luckily I managed to
figure it out from the OGNL documentation
(http://www.opensymphony.com/ognl/html/LanguageGuide/basicExpressions.ht
ml):
Under the 'Expression Evaluation' section, it describes how you can
write this:
#variable(#object)
And have OGNL interpret the result of the first expression (#variable)
as another expression to evaluate, using the result of the parenthesized
expression (#object) as the root object for that evaluation.
So, if you have a property name in #variable, and you want to retrieve
the value of the property with that name from the object #object, you
can retrieve it by writing "#variable(#object)".
Hope this is useful to others!
~Jonathan
> -----Original Message-----
> From: Jon Pearson
> Sent: Thursday, May 07, 2009 1:14 PM
> To: Struts Users Mailing List
> Subject: Dynamic property names
>
> I am trying to build out a table of values. I would like the
> user to be able to choose which columns are visible, and to
> re-order them (not interactively, on a separate page). My
> initial method for implementing this looks something like:
>
> User preferences:
> <column title="i18n.property.prop1">property1</column>
> <column title="i18n.property.prop2">property2</column>
> ...
>
> And then something like this for displaying:
> <table>
> <tr>
> <s:iterator value="prefs">
> <th><s:text name="content" /></th>
> </s:iterator>
> </tr>
>
> <s:iterator value="rows">
> <tr>
> <s:iterator value="prefs">
> <td><s:property
> value="%{getAttribute('title')}" /></td>
> </s:iterator>
> </tr>
> </s:iterator>
> </table>
>
> But I'm not sure how to do a double-indirection.
> %{getAttribute('title')} is going to return something like "property1"
> or "property2", but what I really want is to have OGNL go
> back out and retrieve the value associated with that name, as
> if I had typed '<s:property value="property1" />'. Is there a
> way to do this?
>
> Jonathan P. Pearson - Software Engineer
> --------------------------------------------------
> SIXNET - Solutions for Your Industrial Networking Challenges
> 331 Ushers Road, Ballston Lake, NY 12019
> Tel: 1.518.877.5173, Fax: 1.518.877.8346 www.sixnet.com
>
> ---------------------------------------------------------------------
> 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]