A Struts process can be divided into several modules. For example, in a credit card application process, you can have a main module to take care of the whole application process and a sub-module to collect credit card owner information. After the sub-module finishes collecting card owner information, the main module submits the information for processing
The tookit Struts Extensions component enables you to define modules and sub-modules for your Struts process. Each module has its own Struts configuration file. The different struts-config files are specified as parameters to the Struts ActionServlet or its subclass in the web.xml file of your application EAR file. To preserve session management, you can only switch to modules in the same EAR file. The Session Manager manages data sharing and access.
<action path="/creditCardWellcome" forward="/creditCardsWellcome.jsp"/> <action name="creditCardForm" path="/apply" className="com.ibm.btt.struts.config.BTTSwitchActionMapping" type="org.apache.struts.actions.SwitchAction" processCtxMapperTo="mapper1" processCtxMapperFrom="mapper2" input="/creditCardsWellcome.jsp" validator="com.ibm.btt.samples.html.ApplyXVal"> <forward name="success" contextRelative="true" path="/financialInfo/requestDataPage.jsp "/> <forward name="creditCardsPage" path="/creditCardsPage.jsp"/> </action> <processctxmappers> <processctxmapper id="mapper1"> <ctxmaps from="firstName" to="firstName"/> <ctxmaps from="middleName" to="middleName"/> <ctxmaps from="lastName" to="lastName"/> <ctxmaps from="income" to="income"/> <ctxmaps from="security" to="security"/> <ctxmaps from="social" to="social"/> <ctxmaps from="number" to="number"/> </processctxmapper> <processctxmapper id="mapper2"> <ctxmaps from="firstName" to="firstName"/> <ctxmaps from="middleName" to="middleName"/> <ctxmaps from="lastName" to="lastName"/> <ctxmaps from="income" to="income"/> <ctxmaps from="security" to="security"/> <ctxmaps from="social" to="social"/> <ctxmaps from="number" to="number"/> </processctxmapper> </processctxmappers> <flowcontext contextName="creditCardCtx" local="true"/>
<btt:form action="/apply.do?prefix=/btt/html/creditCard/financialInfo&page=/finacialInfo.do"> <center> <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="75%"><TR><TD> <CENTER><btt:errors /></CENTER> </TD></TR><TR><TD> <input type="radio" name="userType" value="new" checked="checked"> <btt:label text="I_do_not_have_an_account" /> </TD></TR><TR><TD> </TD><TR><TD><BR> <btt:radio property="userType" value="existing" /> <btt:label text="I_have_an_account" /> <btt:text property="accountNumber" /> </TD></TR><TR><TD ALIGN="center"> <INPUT TYPE="submit" VALUE=<btt:label text="Continue"/>> </TABLE> </center> </btt:form>
<action name="financialInfoForm" path="/finacialInfo" className="com.ibm.btt.struts.config.BTTEJBActionMapping" type="com.ibm.btt.struts.actions.EJBAction" input="/requestDataPage.jsp" invokerId="financialinfoinvoker"> <forward name="success" path="/requestDataPage.jsp"/> </action> <action name="financialInfoForm" path="/finacialFinal" className="com.ibm.btt.struts.config.BTTEJBActionMapping" type="com.ibm.btt.struts.actions.EJBAction" input="/requestDataPage.jsp" invokerId="financialfinalinvoker" validator="com.ibm.btt.samples.html.FinancialInfoXVal"> <forward name="creditCardsPage" path="/creditCardsPage.jsp"/> <forward name="cancel" path="/cancelConfirmation.jsp"/> </action> <finals> <final type="forward" name="/creditCardsPage.jsp"/></finals>The financialInfo action then calls the financialinfoinvoker invoker to invoke a business process or Single Action EJB through the EJB Access Action to do the transaction.
As defined in the <final> tag, when any action in the sub-module has an ActionForward to the creditCardsPage.jsp page, the Struts process exits from the sub-module.