struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Van Wart <sc...@indosoft.ca>
Subject Re: Global forwards don't support Tiles definitions?
Date Thu, 01 Jun 2006 19:06:16 GMT
OK I went with the following workaround.  I create a form bean to handle 
the name of the "global" forward:

public class ForwardForm extends ActionForm {
  private String name;
  public ForwardForm() { }
  public String getName() { return this.name; }
  public void setName( String name ) { this.name = name; }
  public void reset( ActionMapping mapping, HttpServletRequest request ) 
{ this.name = ""; }
}

Then an Action that simply passes the name to findForward:

public class ForwardAction extends Action {
  public ActionForward execute( ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response ) throws 
Exception { return mapping.findForward( ( (ForwardForm)form ).getName() ); }

Then my form-bean and action definitions for the above two classes in 
struts-config.xml:

<form-bean name="forwardForm" type="org.whatever.ForwardForm" />
...
<action path="/forward" type="org.whatever.ForwardAction" 
name="forwardForm" scope="request" validate="false">
    <!-- The "real" forward targets appear here at first -->
    <forward name="main" path="page.main" redirect="true" />
</action>

Then to make it so I can actually use global forwards now (the idea 
being the global forwards actually forward to an action which CAN handle 
tiles definitions), I define my global forwards like so:

<forward name="main" path="/forward.do?name=main" />

(instead of just putting path="page.main", which doesn't work)

So it ends up being an extra step of redirection, but I don't care.  
Once it's all set up, aside from having to define two forwards (two XML 
tags; no big deal), I can always collapse the definitions if tiles 
support is added to global forwards in the future.

Hope this helps somebody :).

- Scott


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message