L
loggin
Hi,
Having worked with several web dev languages I've gotten use to
designing sites with particular style and that allow for quick and
easy template updates (some sites have had over 12000 pages) usually
the templates are controlled from one template(skin) file with the
pages individual content being placed into zones/regions defined in
the template, however so far the closest I've come to finding a
solution in jsp means chopping up my template into several files and
then using includes to place them in my page, so it looks sumfin like:
<%@ include file="top.jsp" %>
<h1>Welcome Title</h1>
<%@ include file="nav.jsp" %>
My main content
<%@ include file="ads.jsp" %>
<%@ include file="footer.jsp" %>
but although the skin is centrally controlled its not ideal as the
file is now split across several files and also if I wanted my main
content to appear before my navigation I would have to go into each
individual file still and reorganise it manually, what I'm really
looking for is a technique to encapsulate my content in a function
like container which is then lifted and placed into the zones defined
in my template with a getFunction like call, does anyone know of
anything already in existence ?
Below is an example of I would ideally like to structure my files,
well not quite so ideal as I have to put the doctype at the very top
of my code which is just a pain, if I can't find something like I'm
going to start trying to write my own tag to do it.
<!-- mypage.jsp -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html40/strict.dtd">
<%@ page language="java" contentType="text/html" %>
<%@ taglib uri="/WEB-INF/tlds/custom.tld" prefix="r" %><r:Function
id="header" return="true">
<h1>Page Specific Header Content</h1>
</r:Function>
<r:Function id="content" return="true">
Page Specific Content
<r:Set name="{pagecontext.title}" value="Dynamic Title" />
</r:Function>
<r:Function id="title" return="true">
Page Specific Title - <r:Get name="{pagecontext.title}" />
</r:Function>
<r:Test name="request.template" test="==" value="1">
<%@ include file="temp.jsp" %>
</r:Test>
<r:Test name="request.template" test="==" value="2">
<%@ include file="temp2.jsp" %>
</r:Test>
<!-- end mypage.jsp -->
<!-- temp.jsp -->
<%@ include file="/assets/inc/outerhtml.jsp" %>
<%@ include file="/assets/inc/functions.jsp" %>
<%@ include file="nav.jsp" %>
<%@ include file="footer.jsp" %>
<html>
<head>
<title><r:getFunction name="title" /></title>
<%@ include file="/assets/inc/styles.jsp" %>
<%@ include file="/assets/inc/scripts.jsp" %>
</head>
<body>
<div>
<div>
<r:getFunction name="header" />
</div>
<div>
<r:getFunction name="nav" />
</div>
<div>
<r:getFunction name="content" />
</div>
<div>
<r:getFunction name="footer" />
</div>
</div>
</body>
</html>
<!-- end temp.jsp -->
<!-- temp2.jsp -->
<%@ include file="/assets/inc/outerhtml.jsp" %>
<%@ include file="/assets/inc/functions.jsp" %>
<%@ include file="nav.jsp" %>
<%@ include file="footer.jsp" %>
<html>
<head>
<title><r:getFunction name="title" /></title>
<%@ include file="/assets/inc/styles.jsp" %>
<%@ include file="/assets/inc/scripts.jsp" %>
</head>
<body>
<div>
<div>
<r:getFunction name="header" />
</div>
<div>
<div style="float:left;">
<r:getFunction name="nav" />
</div>
<div style="float:right;">
<div>
<r:getFunction name="content" />
</div>
<div>
<r:getFunction name="footer" />
</div>
</div>
</div>
</div>
</body>
</html>
<!-- end temp2.jsp -->
Having worked with several web dev languages I've gotten use to
designing sites with particular style and that allow for quick and
easy template updates (some sites have had over 12000 pages) usually
the templates are controlled from one template(skin) file with the
pages individual content being placed into zones/regions defined in
the template, however so far the closest I've come to finding a
solution in jsp means chopping up my template into several files and
then using includes to place them in my page, so it looks sumfin like:
<%@ include file="top.jsp" %>
<h1>Welcome Title</h1>
<%@ include file="nav.jsp" %>
My main content
<%@ include file="ads.jsp" %>
<%@ include file="footer.jsp" %>
but although the skin is centrally controlled its not ideal as the
file is now split across several files and also if I wanted my main
content to appear before my navigation I would have to go into each
individual file still and reorganise it manually, what I'm really
looking for is a technique to encapsulate my content in a function
like container which is then lifted and placed into the zones defined
in my template with a getFunction like call, does anyone know of
anything already in existence ?
Below is an example of I would ideally like to structure my files,
well not quite so ideal as I have to put the doctype at the very top
of my code which is just a pain, if I can't find something like I'm
going to start trying to write my own tag to do it.
<!-- mypage.jsp -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html40/strict.dtd">
<%@ page language="java" contentType="text/html" %>
<%@ taglib uri="/WEB-INF/tlds/custom.tld" prefix="r" %><r:Function
id="header" return="true">
<h1>Page Specific Header Content</h1>
</r:Function>
<r:Function id="content" return="true">
Page Specific Content
<r:Set name="{pagecontext.title}" value="Dynamic Title" />
</r:Function>
<r:Function id="title" return="true">
Page Specific Title - <r:Get name="{pagecontext.title}" />
</r:Function>
<r:Test name="request.template" test="==" value="1">
<%@ include file="temp.jsp" %>
</r:Test>
<r:Test name="request.template" test="==" value="2">
<%@ include file="temp2.jsp" %>
</r:Test>
<!-- end mypage.jsp -->
<!-- temp.jsp -->
<%@ include file="/assets/inc/outerhtml.jsp" %>
<%@ include file="/assets/inc/functions.jsp" %>
<%@ include file="nav.jsp" %>
<%@ include file="footer.jsp" %>
<html>
<head>
<title><r:getFunction name="title" /></title>
<%@ include file="/assets/inc/styles.jsp" %>
<%@ include file="/assets/inc/scripts.jsp" %>
</head>
<body>
<div>
<div>
<r:getFunction name="header" />
</div>
<div>
<r:getFunction name="nav" />
</div>
<div>
<r:getFunction name="content" />
</div>
<div>
<r:getFunction name="footer" />
</div>
</div>
</body>
</html>
<!-- end temp.jsp -->
<!-- temp2.jsp -->
<%@ include file="/assets/inc/outerhtml.jsp" %>
<%@ include file="/assets/inc/functions.jsp" %>
<%@ include file="nav.jsp" %>
<%@ include file="footer.jsp" %>
<html>
<head>
<title><r:getFunction name="title" /></title>
<%@ include file="/assets/inc/styles.jsp" %>
<%@ include file="/assets/inc/scripts.jsp" %>
</head>
<body>
<div>
<div>
<r:getFunction name="header" />
</div>
<div>
<div style="float:left;">
<r:getFunction name="nav" />
</div>
<div style="float:right;">
<div>
<r:getFunction name="content" />
</div>
<div>
<r:getFunction name="footer" />
</div>
</div>
</div>
</div>
</body>
</html>
<!-- end temp2.jsp -->