Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleweb.xml
<servlet id="Struts2PortletDispatcherServlet">
    <servlet-name>Struts2PortletDispatcherServlet</servlet-name>
    <servlet-class>org.apache.struts2.portlet.dispatcher.DispatcherServlet</servlet-class>
</servlet>
Note

If you're only using Struts 2 tags, configuring the dispatcher servlet is optional

Portlet Phases

The portlet specification describes that a portlet request cycle can consist of two phases, an event phase and a render phase. In case of an event in the portlet, it will always execute before the render phase. The event phase is typically for changing the state of the application. In a portlet, this is typically when a form is submitted. The render phase will then prepare and dispatch to the view. It's recommended that you set up the result from an action that is executed in the event phase to point to another action that is executed in the render phase, which again is responsible for dispatching to the actual view.

...

The action executed in event mode can pass render parameters to the next action to execute in render mode through a query string in the result configurationparameters using the redirectAction result type:

Code Block
XML
titleXMLstruts.xml
<result type="redirectAction" name="success">/displayCart.action?userId=${userId}
    <param name="actionName">displayCart</param>
    <param name="userId">${userId}</param>
</result>

This will set up a render parameter called userId with the value of the userId property of the dispatching action.