aspose file tools*
The moose likes Struts and the fly likes Struts Tiles - Passing a parameter from layout template into a tile JSP? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Tiles - Passing a parameter from layout template into a tile JSP?" Watch "Struts Tiles - Passing a parameter from layout template into a tile JSP?" New topic
Author

Struts Tiles - Passing a parameter from layout template into a tile JSP?

Pooja Salaria
Greenhorn

Joined: Mar 24, 2009
Posts: 3
I am creating a web app using Tomcat v4.1, JDK v1.4.2, and Struts v1.1 (with Tiles). The format/layout of each JSP in our web app is controlled by a Tiles layout template (call it Layout.jsp). Layout.jsp in turn "inserts" or uses Header.jsp as one of it's tiles to display a common header on each page. Also contained in Header.jsp is some code for a navigation menu at the top of the header/page ("i.e like -> Main | Download | Search | Help | Contact Us").

What I want to be able to do is somehow pass a parameter into Header.jsp that indicates which page I am currently on, so that I can disable that page link, and enable all of the other page links.

So to try and simplify this: I have a content JSP called Mainmenu.jsp. I want to setup a parameter in Mainmenu.jsp, that gets passed through Layout.jsp, and into Header.jsp so that I can disable just the "Main" link, and enable the remaining page links. I have looked over tiles tags but I am not sure how to go about doing this. Or maybe there is a better way to approach this all together ? Any help/ideas would be MOST appreciated!

Hopefully this makes sense - Thanks In Advance!

Mark


RELEVENT CODE SNIPPETS:

LAYOUT.JSP
--------------
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<html:html>
<head>
<title><tiles:getAsString name="pagetitle" /></title>
<tiles:insert attribute="pageheader"/>
</head>
...

MAINMENU.JSP
-----------------
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>

<tiles:insert page="/Layout.jsp" flush="true">

<tiles:put name="pagetitle" type="string"> <bean:message key="title.mainmenu" /> </tiles:put>

***** WANT TO PASS PARAMETER INTO THIS TILE! *****
<tiles:put name="pageheader" value="/Header.jsp" />

HEADER.JSP
--------------
***** WHAT STATEMENT(s) WOULD I NEED TO GET THE PARAMETER TO PROPERLY SETUP THE LINKS ? *****
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Tiles - Passing a parameter from layout template into a tile JSP?