• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Using Tiles Definition As ActionForward

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 17665
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jack J. Jackson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 314
2
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"/>
?
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic