Generic struts action to foward to Tiles pages
Submitted by Ahmed Hashim on Thu, 2006-04-13 23:57.
I had a problem with Struts tiles, every time you want to view a page you have
defined in your tiles-def you have to make an action to forward to it, or
define it in the global forwards.
I consider this as a duplicates of the definition, specially because you really
don't have to do any other thing.
I solved the problem using the wild card struts action definition.
This will let you make a generic action to forward to all your pages.
See this example
tiles-def.xml
the tiles-def.xml contain the pages definitions. And the following struts-config.xml will contain the actions and forwards:
if you request from your browser the action __DisplayLogin.do__ this will forward to viewLogin.page
I think it is a great solution. I hope that this can help anyone to find the Struts best practice.






I'm not sure Ahmed; but have
I'm not sure Ahmed; but have you tried the 'forward' attribute of the action element?
<action path=".." forward=".."/>
It's available in both 1.1 and 1.2 dtds and It's working for me.
Sure Tamer it is
Sure Tamer it is working!
But you have to define a forward for every page, if you have 100 page, and want to view those pages, you have to make a 100 foward action to them. Instead you can use this generic forward action definition to forward to the pages you request.
Ahmed Hashim
Aha
Got it.
Yes, it could be a time saver. Thx.