Search code examples
struts2strutsstruts-1

Are there any tags In Struts2 that emulate the 'nested' tag of Struts 1?


Basically I want to emulate this tag (and behaviour) from Struts 1 in Struts 2: Example...

<nested:write property="myNestedLevel.propertyOne" />
<nested:write property="myNestedLevel.propertyTwo" />
<nested:write property="myNestedLevel.propertyThree" />

Can instead become...

<nested:nest property="myNestedLevel" >
  <nested:write property="propertyOne" />
  <nested:write property="propertyTwo" />
  <nested:write property="propertyThree" />
</nested:nest >

I create View Model objects for each of my Views. As some of these views maybe re used in other View JSP files, the View JSP nested in a View would have an equivalent ViewModel Object nested in another ViewModelObject which represents The Whole View with the nested (reused) View components.

Can anyone think of a way of doing this?


Solution

  • The easiest, obvious approach is to use <s:push>:

    <s:push value="myNestedLevel">
      ${propertyOne}
      ${propertyTwo}
      ${propertyThree}
    </s:push>