You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Ruegger <cr...@speakeasy.net> on 2002/12/04 12:18:40 UTC
tiles: some questions
Question 1:
I'm setting up an app to use Tiles. I'm using tiles definitions
in an XML file and I successfully start at my welcome page,
which is inserted into the master template.
Now suppose this page has direct links to other JSPs,
like this:
<html:link page="nextpage.jsp">next page</html:link>
When I follow this link, it does take me to the page, but the page
is not inserted into the template page. How should I set up
the links so that my pages always show up within my master
template? It looks like I will need to create an entry in the
tiles-defs.xml for each JSP (not a problem), but do I also have to
create an Action class even if all I want to do is just navigate to the
page with no special need for a controller class, and then use
an ActionForward in struts-config.xml that points to an entry
in tiles-defs.xml? Specifically, what should the code for this link
be, and what should I have in struts-config.xml and tiles-defs.xml
to make this work?
Question 2:
When using tiles, should my JSPs now be "fragments", i.e. not
contain <html>, <head>, <body> tags, etc. since those tags
will come from my template page?
Thanks
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: tiles: some questions
Posted by John Nicholas <ja...@mobosplash.com>.
Chris Ruegger wrote:
> Question 1:
> I'm setting up an app to use Tiles. I'm using tiles definitions
> in an XML file and I successfully start at my welcome page,
> which is inserted into the master template.
>
> Now suppose this page has direct links to other JSPs,
> like this:
>
> <html:link page="nextpage.jsp">next page</html:link>
>
> When I follow this link, it does take me to the page, but the page
> is not inserted into the template page. How should I set up
> the links so that my pages always show up within my master
> template? It looks like I will need to create an entry in the
> tiles-defs.xml for each JSP (not a problem), but do I also have to
> create an Action class even if all I want to do is just navigate to the
> page with no special need for a controller class, and then use
> an ActionForward in struts-config.xml that points to an entry
> in tiles-defs.xml? Specifically, what should the code for this link
> be, and what should I have in struts-config.xml and tiles-defs.xml
> to make this work?
>
Yes, you want to have all page access go through the controller even
when it seems like it's not doing anything. There is a default Action
for this.
<action path="/mypath"
type="com.aapromo.RestrictedForewardAction" >
<forward name="success" path="/defs/tilesdefsample" />
</action>
the forward above is to a entry in the tiles-def.xml
<definition name="/defs/tilesdefsample" extends="mainLayout">
<put name="bodycontent" value="/WEB-INF/pages/page_content.jsp" />
</definition>
This lets the controller hand your page off to tiles for the layout and
you have a virtual path to the page. This let's you use the <html:link>
tag to reach it no matther how you change it later and it makes it
easier to add a custom action if you later need it.
> Question 2:
> When using tiles, should my JSPs now be "fragments", i.e. not
> contain <html>, <head>, <body> tags, etc. since those tags
> will come from my template page?
>
Yes, just the content, no outer <html> or <body> tags. I like to make
each of my tiles have a complete table so it's easier to move around as
the layout changes but that's not necessary.
John Nicholas
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>