use of #variable(#object) may lead to ArrayIndexOutOfBoundsException as an alternative i would've suggested an ArrayList of Prop1 embedded within Prop2 this way your ognl ref is always referencing Prop2 (for outer loop) and then reference the Prop1 Array with a get(index) or indexOf(Object) where the acquired index<Prop2.size() to ensure the index is safe to use
Martin ______________________________________________ Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents. Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Subject: RE: Dynamic property names > Date: Fri, 8 May 2009 09:24:09 -0400 > From: jon.pear...@sixnet.com > To: user@struts.apache.org > > 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: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > _________________________________________________________________ Insert movie times and more without leaving Hotmail®. http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd1_052009