File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Java SE 8 for the Really Impatient
this week in the
Joined: Feb 13, 2008
Mar 04, 2008 21:58:00
How do I add action to a common element (header.jsp) for tile layout?
Joined: Sep 15, 2007
Mar 05, 2008 16:40:00
Hi Hong Yi,
If I understand your question, you want to use header.jsp in several tiles?.?.
That being the case, you can extend a tile from a parent. Example:
Suppose you have an action mapping in your struts-config.xml to display your home page, which you want to incorporate header.jsp
<action path="/ShowHome" type="org.apache.struts.actions.ForwardAction" parameter="tile:showhome" />
In your tiles-defs.xml, do the following:
<definition name="tile:layout" path="/jsp/common/layout.jsp"> <put name="page.header" value="/jsp/common/header.jsp" /> </definition> <definition name="tile:showhome" extends="tile:layout"> <put name="page.body" value="/jsp/content/home.jsp" /> </definition>
In this case, tile:showhome inherits tile:layout which contains header.jsp.
Now, in layout.jsp, do something like this:
<%@ taglib uri='http://jakarta.apache.org/struts/tags-tiles' prefix='tiles' %> <!-- html header (not header.jsp) stuff goes here --> <body> <!-- tile for header.jsp --> <tiles:insert attribute="page.header" /> <!-- tile for page body --> <tiles:insert attribute="page.body" /> </body> <!-- html closing tags -->
Now, you can reuse layout by extending it in other tiles and changing the page.body name attribute to whatever jsp applies for the other pages.
I hope that answers your question...
-- Nothing is impossible if I'mPossible
I agree. Here's the link:
subject: tile question
Post your photo!!
Unable to find the path attribute files
Including JSPX in other JSPX
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014