Apache Struts 2 Documentation > Home > Guides > Tag Developers Guide > Struts Tags > Tag Reference > Generic Tag Reference > push
Added by digi9ten, last edited by Ted Husted on Sep 02, 2006  (view change)
Please make sure you have read the Tag Syntax document and understand how tag attribute syntax works.

Description

Content pulled from external source. Click here to refresh.

Push value on stack for simplified usage.

Parameters

Content pulled from external source. Click here to refresh.

Name

Required

Default

Type

Description

value true   Object/String Value to push on stack
id false   Object/String id for referencing element. For UI and form tags it will be used as HTML id attribute

Examples

Content pulled from external source. Click here to refresh.
<ww:push value="user">
    <ww:propery value="firstName" />
    <ww:propery value="lastName" />
</ww:push>
Content pulled from external source. Click here to refresh.
Pushed user into the stack, and hence property tag could access user's properties 
(firstName, lastName etc) since user is not at the top of the stack
Content pulled from external source. Click here to refresh.
<ww:push value="myObject">                              ----- (1)
      <ww:bean name="jp.SomeBean" id="myBean"/>        ----- (2)
		    <ww:param name="myParam" value="top"/>        ----- (3)
      </ww:bean>
  </ww:push>
Content pulled from external source. Click here to refresh.
when in (1), myObject is at the top of the stack
when in (2), jp.SomeBean is in the top of stack, also in stack's context with key myBean
when in (3), top will get the jp.SomeBean instance
Content pulled from external source. Click here to refresh.
<ww:push value="myObject">                                       ---(A)
   <ww:bean name="jp.SomeBean" id="myBean"/>                   ---(B)
      <ww:param name="myParam" value="top.mySomeOtherValue"/>  ---(C)
   </ww:bean>
</ww:push>
Content pulled from external source. Click here to refresh.
when in (A), myObject is at the top of the stack
when in (B), jp.SomeBean is at the top of the stack, also in context with key myBean
when in (C), top refers to jp.SomeBean instance. so top.mySomeOtherValue would invoke SomeBean's mySomeOtherValue() method
Content pulled from external source. Click here to refresh.
<ww:push value="myObject">                                 ---- (i)
   <ww:bean name="jp.SomeBean" id="myBean"/>             ---- (ii)
      <ww:param name="myParam" value="[1].top"/>         -----(iii)
   </ww:bean>
</ww:push>
Content pulled from external source. Click here to refresh.
when in (i), myObject is at the top of the stack
when in (ii), jp.SomeBean is at the top of the stack, followed by myObject
when in (iii), [1].top will returned top of the cut of stack starting from myObject, namely myObject itself