org.apache.struts2.result

## Class PostbackResult

- java.lang.Object
- - org.apache.struts2.result.StrutsResultSupport
  - - org.apache.struts2.result.PostbackResult

- All Implemented Interfaces:
    Result, Serializable, StrutsStatics

      public class PostbackResult
      extends StrutsResultSupport

  A result that renders the current request parameters as a form which immediately submits a postback to the specified destination.

  Parameters:

  - location - http location to post the form
  - prependServletContext (true|false) - when location is relative, controls if to add Servlet Context, default "true"
  - actionName - action name to post the form (resolved as an expression)
  - namespace - action's namespace to use (resolved as an expression)
  - method - actions' method to use (resolved as an expression)
  - cache (true|false) - when set to true adds cache control headers, default "true"
  - parse (true|false) - when set to true actionName, namespace and method are parsed, default "true"

  Examples:

       <action name="registerThirdParty" >
         <result type="postback">https://www.example.com/register</result>
       </action>

       <action name="registerThirdParty" >
         <result type="postback">
           <param name="namespace">/secure</param>
           <param name="actionName">register2</param>
         </result>
       </action>

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ActionMapper` | `actionMapper`

    - ### Fields inherited from class org.apache.struts2.result.StrutsResultSupport

      `DEFAULT_PARAM, DEFAULT_URL_ENCODING, parseLocation`

    - ### Fields inherited from interface org.apache.struts2.StrutsStatics

      `ACTION_MAPPING, HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_ACTION_TAG_INVOCATION, STRUTS_PORTLET_CONTEXT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PostbackResult()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doExecute(String finalLocation, ActionInvocation invocation)` Executes the result given a final location (jsp page, action, etc) and the action invocation (the state in which the action was executed).
    `void` | `execute(ActionInvocation invocation)` Implementation of the `execute` method from the `Result` interface.
    `protected boolean` | `isElementIncluded(String name, String[] values)` Determines if the specified form input element should be included.
    `protected String` | `makePostbackUri(ActionInvocation invocation)`
    `void` | `setActionMapper(ActionMapper mapper)`
    `void` | `setActionName(String actionName)` Sets the name of the destination action.
    `void` | `setCache(boolean cache)` Stores the option to cache the rendered intermediate page.
    `void` | `setMethod(String method)` Sets the method of the destination action.
    `void` | `setNamespace(String namespace)` Sets the namespace of the destination action.
    `void` | `setPrependServletContext(boolean prependServletContext)`
    `protected void` | `writeFormElement(PrintWriter pw, String name, String[] values)`
    `protected void` | `writePrologueScript(PrintWriter pw)` Outputs the script after the form has been emitted.

    - ### Methods inherited from class org.apache.struts2.result.StrutsResultSupport

      `conditionalParse, conditionalParseCollection, getLastFinalLocation, getLocation, setEncode, setLocation, setParse`

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

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

- - ### Field Detail

    - #### actionMapper

          protected ActionMapper actionMapper

  - ### Constructor Detail

    - #### PostbackResult

          public PostbackResult()

  - ### Method Detail

    - #### doExecute

          protected void doExecute(String finalLocation,
                                   ActionInvocation invocation)
                            throws Exception

      Description copied from class: `StrutsResultSupport`
      Executes the result given a final location (jsp page, action, etc) and the action invocation (the state in which the action was executed). Subclasses must implement this class to handle custom logic for result handling.
      Specified by:
        `doExecute` in class `StrutsResultSupport`
      Parameters:
        `finalLocation` - the location (jsp page, action, etc) to go to.
        `invocation` - the execution state of the action.
      Throws:
        `Exception` - if an error occurs while executing the result.

    - #### execute

          public void execute(ActionInvocation invocation)
                       throws Exception

      Description copied from class: `StrutsResultSupport`
      Implementation of the `execute` method from the `Result` interface. This will call the abstract method `StrutsResultSupport.doExecute(String, ActionInvocation)` after optionally evaluating the location as an OGNL evaluation.
      Specified by:
        `execute` in interface `Result`
      Overrides:
        `execute` in class `StrutsResultSupport`
      Parameters:
        `invocation` - the execution state of the action.
      Throws:
        `Exception` - if an error occurs while executing the result.

    - #### isElementIncluded

          protected boolean isElementIncluded(String name,
                                              String[] values)

      Determines if the specified form input element should be included.
      Parameters:
        `name` - the input element name
        `values` - the input element values
      Returns:
        `true` if included; otherwise `false`

    - #### makePostbackUri

          protected String makePostbackUri(ActionInvocation invocation)

    - #### setActionMapper

          public final void setActionMapper(ActionMapper mapper)

    - #### setActionName

          public final void setActionName(String actionName)

      Sets the name of the destination action.
      Parameters:
        `actionName` - the action name

    - #### setCache

          public final void setCache(boolean cache)

      Stores the option to cache the rendered intermediate page. The default is `true`.
      Parameters:
        `cache` - enable/disable cache

    - #### setMethod

          public final void setMethod(String method)

      Sets the method of the destination action.
      Parameters:
        `method` - the method

    - #### setNamespace

          public final void setNamespace(String namespace)

      Sets the namespace of the destination action.
      Parameters:
        `namespace` - the namespace

    - #### setPrependServletContext

          public final void setPrependServletContext(boolean prependServletContext)

    - #### writeFormElement

          protected void writeFormElement(PrintWriter pw,
                                          String name,
                                          String[] values)
                                   throws UnsupportedEncodingException

      Throws:
        `UnsupportedEncodingException`

    - #### writePrologueScript

          protected void writePrologueScript(PrintWriter pw)

      Outputs the script after the form has been emitted. The default script is to submit the form using a JavaScript time out that immediately expires.
      Parameters:
        `pw` - the print writer

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