Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Struts and the fly likes Tiles template definition + Struts Action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Tiles template definition + Struts Action" Watch "Tiles template definition + Struts Action" New topic
Author

Tiles template definition + Struts Action

Oliver Ng
Greenhorn

Joined: Aug 28, 2001
Posts: 15
Hi all,

I did a search and didn't find any information so, here is my quesiton:

I'm using a tiles definition xml, and I would like to have a header be dynamically picked based on what information is taken from a database.

Now I realize, i could, technically do whatever processing I need to in a JSP, but I'd like to use a Struts Action to determine what header file to include. My current XML is this:


now I was wondering if it's acceptable to do this in the "header" value:


is this possible? and how would I be able to pass a different value URL to the header "put" definition?

thanks for any or all help
Cheers,
Oliver
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

by my understanding, tiles only understands a few extensions and will complain if it sees anything else.

I recommend having header.jsp be dynamic enough to handle what you need.


A good workman is known by his tools.
Oliver Ng
Greenhorn

Joined: Aug 28, 2001
Posts: 15
actually, i'm getting close but not quite there yet.

I'm using

to create an action that puts the needed attributes into the tiles:insert html tag, but i've run into an issue that i'm baffled with.

I can't seem to get the insert tag to read the attribute given to it by my controller action, instead it seem to read the header value right away.

maybe what i'm doing is wrong but somehow i feel like i'm on kind of the right track? anybody?
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

I believe tiles are processed before anything else, preventing you from inserting a dynamic value there.
Oliver Ng
Greenhorn

Joined: Aug 28, 2001
Posts: 15
OK, i've finally managed a way to do it



this actually seems to work as it overwrites the HEADER attribute in the definition, based on what my action wants to do.

I've run into another problem though. Is there a way to forward to an external URL? when i use

it gives forwards the address as http://localhost/MYAPPNAME/http://lcaolhost/ssi/header.jsp

how can i get around this automatic appending of my application root path?

Thanks for your input so far.
[ June 28, 2004: Message edited by: Oliver Ng ]
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
I'm having the same problem, but I don't know how to generate de dynamic jsp from the action... Do you know how to do that?
 
wood burning stoves
 
subject: Tiles template definition + Struts Action