1

I'm using Tiles 2.0 with Struts2 and what I'm trying to do is populate an action bean from the value stack, i.e.

<s:property value="myBean.cod1"/> 

would populate something like AS0000123

Now, what happens if in my tile's definition I have something like this:

<definition name="fieldPurpose1" template="fieldPurposeTemplate.jsp">
    <put-attribute name="field" value="myBean.cod1"/>
</definition>

And so, in the template I'm trying to:

<s:set name="fieldSimple"><tiles:insertAttribute name="field"/></s:set>
<s:property value="%{#fieldSimple}"/>

But what I get is the text myBean.cod1 not the populated one. Any ideas?

Roman C
  • 49,761
  • 33
  • 66
  • 176
josemaria_liso
  • 121
  • 1
  • 7
  • The thing is that in the jsp i don't know the name of the bean's field i'm trying to populate, it is parametrized through a tiles definition and the problem is than i can't use that parametrized value to retrieve the value of the bean's field. I have tried several ways, but they all fail. – josemaria_liso Apr 04 '16 at 06:31

1 Answers1

1

The value is the key, and you can use this key to find another value using OGNL index reference operator.

<s:set name="fieldSimple"><tiles:insertAttribute name="field"/></s:set>
<s:property value="%{#attr[#fieldSimple]}"/>
Community
  • 1
  • 1
Roman C
  • 49,761
  • 33
  • 66
  • 176