You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paul Hodgetts <ph...@agilelogic.com> on 2003/02/15 19:30:12 UTC
Styles and Scripts with Tiles
I'm having a few problems with style sheets and JavaScript when
used with tiles. Perhaps someone can point me in the right
direction.
I have a layout that defines my basic page (something like this,
although I trimmed it a bit for posting):
<html:html>
<head>
<link href="styles/commonStyles.css" rel="stylesheet" type="text/css">
<script language="javascript" type="text/javascript" src="scripts/commonPageScripts.js" />
</head>
<body onLoad="pageInit()">
<tiles:insert attribute="pageHeader" flush="true" />
<tiles:insert attribute="pageContent" flush="true" />
<tiles:insert attribute="pageFooter" flush="true" />
</body>
</html:html>
And let's say I have a contentOne.jsp that is used as a
pageContent tile (just a real simple table for now):
<table class="normalTable">
<tr class="normalHeadingLine">
<td> Column 1 </td>
<td> Column 2 </td>
<td> Column 3 </td>
</tr>
<tr class="normalDataLine">
<td> Data 1 </td>
<td> Data 2 </td>
<td> Data 3 </td>
</tr>
</table>
Issue #1: Sometimes, the pageContent tiles seem to not pick up
the styles pulled in via the link tag, e.g., the "normal" styles
as shown. Are there any particular guidelines anyones know about
why this may or may not happen?
Issue #2: Let's say I have some styles that are specific to one
of the pageContent tiles, e.g., I wanted a specific specialTable
style for this tile only. What would be the best way to make
those styles available? Should I add a link tag to the specific
styles in contentOne.jsp like so:
<link href="styles/specialStyles.css" rel="stylesheet" type="text/css">
<table class="specialTable">
[...]
Or should I add the styles in directly, like so:
<style> .specialDataLine { border: thin black solid; } </style>
<table class="specialTable">
[...]
Or do I need to have a replaceable tiles:insert in the main
layout that can insert some page specific link or styles up in
the head tag, like so:
<html:html>
<head>
<link href="styles/commonStyles.css" rel="stylesheet" type="text/css">
<tiles:insert attribute="pageStyles" flush="true" />
[...]
Is there any benefit in including styles as a link, or by using
a tiles:insert to pull in the actual style text into the page
(other than the server- vs. browser-side include)?
Or is there some other better way?
Issue #3: Similar to styles, sometimes the tiles do not pick up
the scripts pulled in from the layout. Any ideas why?
Issue #4: Similar to styles, what would be the best way to use
some specific scripts for just one tile?
Issue #5: There is some generic initialization that happens for
all pages as part of the pageInit() Javascript method. How can
I define some tile-specific initialization? What I really want
to do is have a default empty contentInit() method, that can be
overridden by a specific content tile if it needs it, but I
don't know of a way to do this. Is there one?
I'd really appreciate any pointers or references or tips for
this kind of thing. I think I have the Tiles pages figured out
pretty well, but now the details like the styles and scripts
seem to be giving me some pain.
Thanks much,
Paul
-----
Paul Hodgetts -- President, Principal Consultant
Agile Logic -- www.agilelogic.com
Consulting, Coaching, Training -- On-Site & Out-Sourced Development
Java, J2EE, C++, OOA/D -- Agile Methods/XP/Scrum, Use Cases, UI/IA
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Styles and Scripts with Tiles
Posted by Brandon Goodin <ma...@phase.ws>.
I use absolute references. From what I see.. you are using a relative
reference. In other words... 'href="styles/commonStyles.css"' would be
better of as 'href="/styles/commonStyles.css"'. Personally, I never use
relative urls. They are too difficult to track and maintain.
I do use the link tag for stylesheet importing with tiles and have no
problems at all.
As for unique styles you could always extend base tile definition and
override a particular put in the overriding definition.
Here's an example:
<definition name="doc.mainLayout" path="/layouts/mainlayout.jsp">
<put name="customcss" value="/tiles/defaultcustomcss.jsp" type="page" />
<put name="commoncss" value="/tiles/commoncss.jsp" type="page" />
<put name="content" value="/tiles/content.jsp" type="page" />
</definition>
<definition name="doc.extendedLayout" extends="doc.mainLayout">
<put name="customcss" value="/tiles/mycustomcss.jsp" type="page" />
</definition>
Brandon Goodin
Phase Web and Multimedia
PO Box 85
Whitefish MT 59937
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws
-----Original Message-----
From: Paul Hodgetts [mailto:phodgetts@agilelogic.com]
Sent: Saturday, February 15, 2003 11:30 AM
To: struts-user@jakarta.apache.org
Subject: Styles and Scripts with Tiles
I'm having a few problems with style sheets and JavaScript when
used with tiles. Perhaps someone can point me in the right
direction.
I have a layout that defines my basic page (something like this,
although I trimmed it a bit for posting):
<html:html>
<head>
<link href="styles/commonStyles.css" rel="stylesheet"
type="text/css">
<script language="javascript" type="text/javascript"
src="scripts/commonPageScripts.js" />
</head>
<body onLoad="pageInit()">
<tiles:insert attribute="pageHeader" flush="true" />
<tiles:insert attribute="pageContent" flush="true" />
<tiles:insert attribute="pageFooter" flush="true" />
</body>
</html:html>
And let's say I have a contentOne.jsp that is used as a
pageContent tile (just a real simple table for now):
<table class="normalTable">
<tr class="normalHeadingLine">
<td> Column 1 </td>
<td> Column 2 </td>
<td> Column 3 </td>
</tr>
<tr class="normalDataLine">
<td> Data 1 </td>
<td> Data 2 </td>
<td> Data 3 </td>
</tr>
</table>
Issue #1: Sometimes, the pageContent tiles seem to not pick up
the styles pulled in via the link tag, e.g., the "normal" styles
as shown. Are there any particular guidelines anyones know about
why this may or may not happen?
Issue #2: Let's say I have some styles that are specific to one
of the pageContent tiles, e.g., I wanted a specific specialTable
style for this tile only. What would be the best way to make
those styles available? Should I add a link tag to the specific
styles in contentOne.jsp like so:
<link href="styles/specialStyles.css" rel="stylesheet" type="text/css">
<table class="specialTable">
[...]
Or should I add the styles in directly, like so:
<style> .specialDataLine { border: thin black solid; } </style>
<table class="specialTable">
[...]
Or do I need to have a replaceable tiles:insert in the main
layout that can insert some page specific link or styles up in
the head tag, like so:
<html:html>
<head>
<link href="styles/commonStyles.css" rel="stylesheet"
type="text/css">
<tiles:insert attribute="pageStyles" flush="true" />
[...]
Is there any benefit in including styles as a link, or by using
a tiles:insert to pull in the actual style text into the page
(other than the server- vs. browser-side include)?
Or is there some other better way?
Issue #3: Similar to styles, sometimes the tiles do not pick up
the scripts pulled in from the layout. Any ideas why?
Issue #4: Similar to styles, what would be the best way to use
some specific scripts for just one tile?
Issue #5: There is some generic initialization that happens for
all pages as part of the pageInit() Javascript method. How can
I define some tile-specific initialization? What I really want
to do is have a default empty contentInit() method, that can be
overridden by a specific content tile if it needs it, but I
don't know of a way to do this. Is there one?
I'd really appreciate any pointers or references or tips for
this kind of thing. I think I have the Tiles pages figured out
pretty well, but now the details like the styles and scripts
seem to be giving me some pain.
Thanks much,
Paul
-----
Paul Hodgetts -- President, Principal Consultant
Agile Logic -- www.agilelogic.com
Consulting, Coaching, Training -- On-Site & Out-Sourced Development
Java, J2EE, C++, OOA/D -- Agile Methods/XP/Scrum, Use Cases, UI/IA
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org