org.apache.struts2.components

## Class Push

- java.lang.Object
- - org.apache.struts2.components.Component
  - - org.apache.struts2.components.Push

-     public class Push
      extends Component

  Push value on stack for simplified usage.

  - value* (Object) - value to be pushed into the top of the stack

  Examples

       <s:push value="user">
           <s:propery value="firstName" />
           <s:propery value="lastName" />
       </s:push>

  Pushed user into the stack, and hence property tag could access user's properties (firstName, lastName etc) since user is now at the top of the stack

        <s:push value="myObject">                              ----- (1)
             <s:bean name="jp.SomeBean" var="myBean"/>        ----- (2)
                <s:param name="myParam" value="top"/>        ----- (3)
             </s:bean>
         </s:push>

       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

       <s:push value="myObject">                                       ---(A)
          <s:bean name="jp.SomeBean" var="myBean"/>                   ---(B)
             <s:param name="myParam" value="top.mySomeOtherValue"/>  ---(C)
          </s:bean>
       </s:push>

       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

       <s:push value="myObject">                                 ---- (i)
          <s:bean name="jp.SomeBean" var="myBean"/>             ---- (ii)
             <s:param name="myParam" value="[1].top"/>         -----(iii)
          </s:bean>
       </s:push>

       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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `pushed`
    `protected String` | `value`

    - ### Fields inherited from class org.apache.struts2.components.Component

      `actionMapper, COMPONENT_STACK, devMode, escapeHtmlBody, parameters, performClearTagStateForTagPoolingServers, stack, standardAttributesMap, throwExceptionOnELFailure`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Push(ValueStack stack)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `end(Writer writer, String body)` Callback for the end tag of this component.
    `void` | `setValue(String value)`
    `boolean` | `start(Writer writer)` Callback for the start tag of this component.

    - ### Methods inherited from class org.apache.struts2.components.Component

      `addAllParameters, addParameter, completeExpression, copyParams, determineActionURL, determineNamespace, end, escapeHtmlBody, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getAttributes, getComponentStack, getNamespace, getParameters, getPerformClearTagStateForTagPoolingServers, getStack, getStandardAttributes, isAcceptableExpression, isValidTagAttribute, popComponentStack, setActionMapper, setDevMode, setEscapeHtmlBody, setNotExcludedAcceptedPatterns, setPerformClearTagStateForTagPoolingServers, setThrowExceptionsOnELFailure, setUrlHelper, stripExpression, toString, usesBody`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### value

          protected String value

    - #### pushed

          protected boolean pushed

  - ### Constructor Detail

    - #### Push

          public Push(ValueStack stack)

  - ### Method Detail

    - #### start

          public boolean start(Writer writer)

      Description copied from class: `Component`
      Callback for the start tag of this component. Should the body be evaluated?
      Overrides:
        `start` in class `Component`
      Parameters:
        `writer` - the output writer.
      Returns:
        true if the body should be evaluated

    - #### end

          public boolean end(Writer writer,
                             String body)

      Description copied from class: `Component`
      Callback for the end tag of this component. Should the body be evaluated again?
      NOTE: will pop component stack.
      Overrides:
        `end` in class `Component`
      Parameters:
        `writer` - the output writer.
        `body` - the rendered body.
      Returns:
        true if the body should be evaluated again

    - #### setValue

          public void setValue(String value)

Copyright © 2000–2025 Apache Software Foundation. All rights reserved.