IncludeAction

 < Day Day Up > 



To understand the IncludeAction, be sure to read about the ForwardAction in the previous section. The IncludeAction is similar to the ForwardAction but is not used as much. You could rewrite the last example using the include action as follows:

          <action              path="/legacy"              type="org.apache.struts.actions.IncludeAction"              parameter="/legacy/roar"              input="/form/userForm2.jsp"              name="userForm"              validate="true"              scope="request"              /> 

This shorter form uses the include attribute:

          <action              path="/legacy"              include="/legacy/roar"              input="/form/userForm2.jsp"              name="userForm"              parameter="/legacy/roar"              validate="true"              scope="request"              /> 

So what is the difference between the IncludeAction and the ForwardAction? The difference is that you need to use the IncludeAction only if the action is going to be included by another action or JSP.

Therefore, if you have code in your JSP that looks like this:

 <jsp:include page="/someWebApp/someModule/someAction.do"/> 

the action could not use a ForwardAction because it would forward control to the new action rather than including its output within the output of the JSP—or throw a nasty IllegalStateException if the output buffer was already committed.

This discussion also applies to using the Tiles framework. A Tile can be a Web resource, and an action can be a Web resource. Thus, you could define a Tile as an action. Refer to Chapters 13 and 17 for more details.



 < Day Day Up > 



Professional Jakarta Struts
Professional Jakarta Struts (Programmer to Programmer)
ISBN: 0764544373
EAN: 2147483647
Year: 2003
Pages: 183

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