Dynamic Include In Decorator
Marcel Overdijk <[email protected]> Thu, 04 Aug 2005 12:59:51 CDT
| Newsgroups | gmane.comp.web.sitemesh.general,gmane.comp.lang.pnuts.user |
|---|---|
| Message-ID | <31684466.1123178422010.JavaMail.os-j2ee@opensymphony01.contegix.com> |
Found the solution myself:
index.jsp:
<html>
<head>
<meta name="decorator" content="main"/>
<meta name="banner" content="/includes/banner1.jsp"/>
<title>Hello world!</title>
</head>
<body>
<h2>Hello world!</h2>
</body>
</html>
main.jsp (decorator):
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page" %>
<html>
<head>
<title>My Site - <decorator:title default="Welcome!" /></title>
<decorator:head />
</head>
<body>
<p><%@ include file="/includes/header.jsp" %></p>
<decorator:usePage id="thePage" />
<% String banner = thePage.getProperty("meta.banner");
if (banner != null && !"".equals(banner)) {
%>
<p><page:applyDecorator name="panel" page="<%= banner %>"/></p>
<% } %>
<p><%@ include file="/includes/menu.jsp" %></p>
<p><decorator:body /></p>
<p><%@ include file="/includes/footer.jsp" %></p>
</body>
</html>
How it works:
In the index.jsp the meta tag is used to set the banner to use.
In the docorator main.jsp the meta is read using the getProperty method.
Then we use this value to apply the panel docorator to.
This simple example is based on the sitemesh-blank.war.
Regards,
Marcel
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=1710&messageID=12142#12142
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]