Modifying Your Actions


The final step in converting the application to use Tiles is to change the action tags in the application to use the Tiles layout names instead of JSP filenames. Listing 16.5 shows the new global forward and action sections of struts-config.xml .

Listing 16.5 Modifications to struts-config.xml
 <global-forwards type="org.apache.struts.action.ActionForward">     <forward name="home" path="stocktrack.index" />     <forward name="portfolio" path="stocktrack.portfolio"/>     <forward name="newUserName" path="stocktrack.newUserName"/>     <forward name="newUserAddress" path="stocktrack.newUserAddress"/> </global-forwards> <action-mappings type="org.apache.struts.action.ActionMapping">     <action path="/index" forward="stocktrack.index" />     <action path="/newaccount" forward="stocktrack.newUserName"/>     <action path="/login" type="stocktrack.struts.action.LoginAction"             name="loginForm" scope="request"/>     <action path="/newUserName" type="stocktrack.struts.action.NewUserNameAction"             name="newUserNameForm" scope="session" input="stocktrack.newUserName"/>     <action path="/newUserAddress"             type="stocktrack.struts.action.NewUserAddressAction"             name="newUserAddressForm" scope="session"             input="stocktrack.newUserAddress"/>     <action path="/portfolio" type="stocktrack.struts.action.PortfolioAction"/>     <action path="/addTransaction"             type="stocktrack.struts.action.AddTransactionAction"             name="addTransactionForm" scope="request"             validate="true" input="stocktrack.portfolio">       <forward name="home" path="stocktrack.portfolio"/>     </action> </action-mappings> 

As you can see, a layout name can be freely used in place of a JSP pathname for a forward 's path attribute or action 's input attribute.



Struts Kick Start
Struts Kick Start
ISBN: 0672324725
EAN: 2147483647
Year: 2002
Pages: 177

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net