Thaigo,
I would take a similar approach to Karen's and effectively extend your
main layout with a weather layout. The nesting of layout tags is a
little complicated and redundant, but it is an effective way to
progressively add functionality to layouts.
Attached is a weather layout. It is also posted at
http://gist.github.com/444099
At this point, if you wanted to add weather functionality to a page, you
would simply do the following:
<stripes:layout-render name="/template/weather.jsp">
<stripes:layout-component name="content">
Your content
</stripes:layout-component>
</stripes:layout-render>
I hope this makes sense.
Regards,
Andy
kdeveloper wrote:
Thiago,
I don't think it's possible to define the needed JS and CSS files in
your 'weather' component, you need to code it explicitly in your JSP page.
Thus you're 'some web page' needs to look like this:
<stripes:layout-render name="/template/main.jsp">
<stripes:layout-component name="content">
<stripes:layout-render name="/component/weather.jsp" />
</stripes:layout-component>
<stripes:layout-component name="css">
<link rel="stylesheet" type="text/css"
href="${contextPath}/css/component/weather.css" />
</stripes:layout-component>
<stripes:layout-component name="js">
<script type="text/javascript"
src="${contextPath}/js/component/weather.js"></script>
</stripes:layout-component>
</stripes:layout-render>
And you're weather.jsp should look like this:
<stripes:layout-definition>
<div class="weather">
<h1>Weather</h1>
<div>Blah Blah Blah</div>
</div>
<stripes:layout-definition>
kind regards,
Karen
On 18-06-10 17:01, Thiago Caiubi wrote:
Hi,
Let's say I have a weather component and I wanna use it in a web page. This component
has html markup, javascript behaviour and css style, and it is in a single JSP inside
a<stripes:layout-definition />.
So I call the weather component in a page like this:<stripes:layout-render
name="/component/weather.jsp" />. This web page where I call the component also
uses the whole application template.
I will write an example to simplify the case...
Main template (main.jsp):
<stripes:layout-definition>
<html>
<head>
<stripes:layout-component name="css" />
</head>
<body>
<stripes:layout-component name="header">
<div>HEADER</div>
<stripes:layout-component>
<stripes:layout-component name="content">
<div>CONTENT</div>
<stripes:layout-component>
<stripes:layout-component name="footer">
<div>FOOTER</div>
<stripes:layout-component>
<stripes:layout-component name="js" />
</body>
</html>
</stripes:layout-definition>
Some web page:
<stripes:layout-render name="/template/main.jsp">
<stripes:layout-component name="content">
<stripes:layout-render name="/component/weather.jsp" />
</stripes:layout-component>
</stripes:layout-render>
Weather component (weather.jsp):
<stripes:layout-definition>
<stripes:layout-component name="css">
<link rel="stylesheet" type="text/css"
href="${contextPath}/css/component/weather.css" />
</stripes:layout-component>
<stripes:layout-component name="js">
<script type="text/javascript"
src="${contextPath}/js/component/weather.js"></script>
</stripes:layout-component>
<div class="weather">
<h1>Weather</h1>
<div>Blah Blah Blah</div>
</div>
<stripes:layout-definition>
Till now everything OK, stripes rocks!!! lol
My need comes here, I want the stylesheet and javascript to be put into layout
component of the main template!
CSS inside<head /> and and JS at the bottom, below the footer component!!
Example of html I would like to be rendered:
<html>
<head>
<link rel="stylesheet" type="text/css"
href="/contextPath/css/component/weather.css" />
</head>
<body>
<div>HEADER</div>
<div class="weather">
<h1>Weather</h1>
<div>Blah Blah Blah</div>
</div>
<div>FOOTER</div>
<script type="text/javascript"
src="/contextPath/js/component/weather.js"></script>
</body>
</html>
Is there any way to do it?
I am looking forward for your answer. Thanks....
Thiago Caiubi
thiago.cai...@gmail.com
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users
<stripes:layout-definition>
<c:set var="css"><stripes:layout-component name="css" /></c:set>
<c:set var="header"><stripes:layout-component name="header" /></c:set>
<c:set var="content"><stripes:layout-component name="content" /></c:set>
<c:set var="footer"><stripes:layout-component name="footer" /></c:set>
<c:set var="js"><stripes:layout-component name="js" /></c:set>
<stripes:layout-render name="/template/main.jsp">
<stripes:layout-component name="css">
<link rel="stylesheet" type="text/css"
href="${contextPath}/css/component/weather.css" />
${css}
</stripes:layout-component>
<stripes:layout-component
name="header">${header}</stripes:layout-component>
<stripes:layout-component name="content">
<!-- Weather-specific content -->
${content}
</stripes:layout-component>
<stripes:layout-component
name="footer">${footer}</stripes:layout-component>
<stripes:layout-component name="js">
<link rel="stylesheet" type="text/css"
href="${contextPath}/css/component/weather.css" />
${js}
</stripes:layout-component>
</stripes:layout-render>
</stripes:layout-definition>
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users