StrutsChain/UsingChainAction

HomePage | StrutsChain | RecentChanges | Preferences

ChainAction has been removed and will not be part of Struts 1.3

Execute the Action

   <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
   <html:link action="/Sort">Sort</html:link>

<a href="/chainapp/Sort.do">Sort</a>

... and clicking on that link will cause the 'sort' chain to be executed by way of ...

Configure a ChainAction

    <action path="/Sort"
           type="org.apache.struts.actions.ChainAction"
          scope="request"
      parameter="sort" >
         <forward  name="success" path="/pages/display.jsp"/>
    </action>

... and parameter="sort" matches up with the name of the chain in the catalog ...

Configure the ChainListener

    <context-param>
        <param-name>org.apache.commons.chain.CONFIG_CLASS_RESOURCE</param-name>
        <param-value>catalogs/webapp-catalog.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.apache.commons.chain.web.ChainListener</listener-class>
    </listener>

... which parses the catalog below ...

Write a catalog

<?xml version="1.0" ?>
<catalog>

  <command
    name="check"
    className="net.wsmoak.chain.commands.CheckList"/>

    <chain name="sort">
       <command
          className="net.wsmoak.chain.commands.CheckList"/>
      <command
          className="net.wsmoak.chain.commands.SortAscending"/>
      <command
          className="net.wsmoak.chain.webapp.Succeed"/>
    </chain>

</catalog>

... the Succeed command puts a 'success' ActionForward in the context, which ChainAction retrieves and returns as the result.

The Missing Details


HomePage | StrutsChain | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited December 19, 2005 10:31 am by WendySmoak (diff)
Search: