aspose file tools*
The moose likes Struts and the fly likes Using Tiles Definition As ActionForward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using Tiles Definition As ActionForward" Watch "Using Tiles Definition As ActionForward" New topic
Author

Using Tiles Definition As ActionForward

Jack J. Jackson
Greenhorn

Joined: Apr 20, 2002
Posts: 27
I'm having a problem getting a tiles definition to be used as an action forward. I'm using Struts 1.1 RC1 and Tomcat 4.03.
The tiles definition is:

The <global-forward> is defined as:
<forward name="home" path=".homeLayout"/>
In a JSP, I have a tag that reads:
<logic:forward name="home" />
When this JSP is requested, the "home" forward is resolved to "/.homeLayout" and Tomcat sends a 404 error with the message: The requested resource (/.homeLayout) is not available.
It appears that the .homeLayout definition isn't being resolved by Struts/Tiles as /common/defaultLayout.jsp with all the included JSP tiles. In looking at the trace log, it appears all of the definitions are being parsed okay, but there's a lot going on during the process I'm not sure about.
My controller servlet subclasses the Tiles ActionComponentServlet and the plug-in is declared like:

I'm sure I've overlooked the obvious, but it's not so obvious to me at the moment! Any advise would be appreciated.


Jack
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5288
    
  10

It seems to me that the logic:forward tag handler is not aware of tiles. You can probably work around this by defining a forwarding action.


Junilu - [How to Ask Questions] [How to Answer Questions]
Jack J. Jackson
Greenhorn

Joined: Apr 20, 2002
Posts: 27
Ouch! That seems to be one more level of indirection than I'd like.
It does seem like the <logic:forward> is doing its job in that it's resolving the forward name to the forward path. It's just that the forward path doesn't get re-evaluated as a Tiles definition.
I'll give your suggestion a try and report back. Thanks so much for your help.
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
Hi there,
I ran into this problem last week. After doing some searching I found that you need to download and install commons-scaffold.jar and struts-scaffold.jar from sourceforge.net and include them with your other JAR files. You also need to integrate Tiles with Struts by including the following plugin definition toward the button of your struts-config.xml file:
<!--******************************************************************-->
<!---->
<!--Define the Tiles plug-in so that we can use Tiles definitions.-->
<!---->
<!--******************************************************************-->
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config"value="/WEB-INF/tiles-defs.xml" />
<set-property property="definitions-debug"value="2" />
<set-property property="definitions-parser-details"value="2" />
<set-property property="definitions-parser-validate"value="true" />
</plug-in>
The file containing the two JAR files can be downloaded from:
http://prdownloads.sourceforge.net/struts/scaffold-lib_1_1_b1.zip
Cheers,
Darryl
Jack J. Jackson
Greenhorn

Joined: Apr 20, 2002
Posts: 27
Thanks for all your help.
It does appear that the <logic:forward> tag hasn't kept up with Tiles.
I did find the suggestion of just adding an forwarding Action to navigate to the Tiles definition worked for me. It's a few extra lines in the Struts config file, but that's okay. (Thanks to the new ForwardAction class, this is really simple.)
On reflection, I think this may be the preferred way to solve the problem architecturally anyway. While Tiles is very nice, tightly coupling all of my JSP code with Tiles references could work today, but may hinder switching to a new web template framework later. This way, the Tiles references are safely hidden away in the declarative syntax of the Struts config file and unknown to my JSP pages.
I considered using the Scaffold code, but decided it may not be fully baked enough yet and would only allow me to do that which I now think should be avoided; i.e. tightly coupling Tiles with my JSPs.
Thanks again.
cord thomas
Greenhorn

Joined: Feb 24, 2004
Posts: 1
i have had problem similar to what was discussed in this thread. the solution basically worked for me - great, but i wonder - if anyone still listening - is this still required? or is struts actionforward now tile-aware- my understanding is it was- but i cannot seem to reference a tiles layout such as .my.layout from a global forward.
so, can one say <global-forwards><forward name="baseforwd" path=".my.layout"/></global-fowards>
and then use <logic:forward name="baseforward"/>
?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Tiles Definition As ActionForward