myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Garner, Shawn" <shawn.gar...@pearson.com>
Subject RE: [JSF] Tiles and Reusable Template
Date Fri, 24 Feb 2006 20:03:22 GMT
<definition name="tile.home" extends="tile.default">
		<put name="title"  value="Home Page Title" />
		<put name="body"   value="/home.jsp" />
	</definition>

This is the part I want to avoid if at all possible.
I don't want to have to declare this in the xml file for every jsp page.

So if you have two more pages you need
<definition name="tile.pageA" extends="tile.default">
		<put name="title"  value="pageA Title" />
		<put name="body"   value="/pageA.jsp" />
</definition>

<definition name="tile.pageB" extends="tile.default">
		<put name="title"  value="pageB Title" />
		<put name="body"   value="/pageB.jsp" />
</definition>

This is very repetitive and you will end up with a giant def file if you
have a lot of pages and I don't see why you need it.

How hard is it to do something like this:
<definition name="tile.default" template="/layout.jsp">
		<put name="title"  value="Default Title" />
		<put name="header"  value="/header.jsp" />
		<put name="body"   value="/placeHolder.jsp" />
		<put name="footer" value="/footer.jsp>

</definition>

add_user.jsp
<tiles:using name="tile.default">
<tiles:put name="title" value="Add User" direct="true" type="String"/>
<tiles:put name="body">
	...controls and content for add_user.jsp...
</tiles:put>
</tiles:using>

The title, header, and footer would come from the default.
You would set the title and body in the jsp page.

Shawn


-----Original Message-----
From: CONNER, BRENDAN (SBCSI) [mailto:bc1378@att.com] 
Sent: Friday, February 24, 2006 1:20 PM
To: MyFaces Discussion
Subject: RE: [JSF] Tiles and Reusable Template

I don't know what you mean by a "bunch of xml files."  We have a
tiles-def.xml file that contains the tiles definitions, plus a layout
jsp used by the tiles definitions.  For example, a tiles-def.xml file
could contain the following entries:

<tiles-definitions>
	<definition name="tile.default" path="/myLayout.jsp">
		<put name="title"  value="MyTitle" />
		<put name="header" value="/standardHeader.jsp"  />
		<put name="menu" value="/standardMenu.jsp" />
		<put name="body"   value="/dummyBody.jsp" /> 
		<put name="footer" value="/standardFooter.jsp"  />
	</definition>
	<definition name="tile.home" extends="tile.default">
		<put name="title"  value="Home Page Title" />
		<put name="body"   value="/home.jsp" />
	</definition>
</tiles-definitions>

where myLayout.jsp has the following entries (typically with a lot of
<h:panelGrid> formatting to make the menu, body, and footer fit in where
you want them):

<html>
	<f:view>
		<head>
			<title><h:outputText value="#{title}"/></title>
		</head>

		<body>
			...
			<f:subview id="menu">
				<tiles:insert attribute="menu"
flush="false" ignore="true"/>
			</f:subview>
			...
			<f:subview id="header">
				<tiles:insert attribute="header"
flush="false" ignore="true" />
			</f:subview>
			...
			<f:subview id="mainSubview">
				<tiles:insert attribute="body"
flush="false" ignore="true"/>
			</f:subview>
			...
			<f:facet name="footer">
				<tiles:insert attribute="footer"
flush="false" ignore="true" />
			</f:facet>
			...
		</body>
	</f:view>
</html>

Then your home.jsp file is a regular JSF file that fits into the layout
specified above.

- Brendan

-----Original Message-----
From: Garner, Shawn [mailto:shawn.garner@pearson.com] 
Sent: Friday, February 24, 2006 11:33 AM
To: 'MyFaces Discussion'
Subject: RE: [JSF] Tiles and Reusable Template


I've used struts template tags a little.  
I've just used tiles on a new struts project recently.
Don't know if I did it the "correct" way both times but it works without
a
bunch of xml definitions files.  

The main problem with tiles in JSF is that it is writing the content to
my
tables out before my tables are written.  

Well it says to do a f:verbatim or h:outputText.  But I don't want to do
that every time I want to write out text or HTML text.  Seems like extra
effort that is not needed.

Also I didn't want to write a new page.tiles xml definition for every
JSP
page.  Also I find it very html designer unfriendly.


I like the facelets approach but I would kind of like to stick with an
Apache product if Clay in Shale would do the same thing with about the
same
amount of work.


Shawn
-----Original Message-----
From: CONNER, BRENDAN (SBCSI) [mailto:bc1378@att.com] 
Sent: Friday, February 24, 2006 11:23 AM
To: MyFaces Discussion
Subject: RE: [JSF] Tiles and Reusable Template

The O'Reilly book "JavaServer Faces" has a section in "Chapter 12: Odds
and Ends" called "Combining JSF Views with Other Content."  That gives
an example of how to use Tiles in JSF.  Also the book "Core JavaServer
Faces" has a Chapter entitled "Subviews and Tiles."

Are you familiar with using Tiles outside of JSF?  If so, we can
concentrate on how to use it within JSF.  Otherwise, you may need some
background on Tiles itself (regardless of its integration with JSF).

- Brendan

-----Original Message-----
From: Garner, Shawn [mailto:shawn.garner@pearson.com] 
Sent: Friday, February 24, 2006 10:38 AM
To: 'MyFaces Discussion'
Subject: RE: [JSF] Tiles and Reusable Template


Somebody posted that page but I don't quite get how it works.

Shawn
-----Original Message-----
From: CONNER, BRENDAN (SBCSI) [mailto:bc1378@att.com] 
Sent: Thursday, February 23, 2006 1:08 PM
To: MyFaces Discussion
Subject: RE: [JSF] Tiles and Reusable Template

We're using Tiles with JSF and have no problems.  Works wonderfully, in
fact.  We just needed to code up a tilesDispatch.jsp to avoid having to
create a page for every tile.  (One of the other threads on the subject
gives a link for how to do this.  If you can't find the link, let me
know.  I think it was on java.net.)

- Brendan

-----Original Message-----
From: Garner, Shawn [mailto:shawn.garner@pearson.com] 
Sent: Thursday, February 23, 2006 12:51 PM
To: 'MyFaces Discussion'
Subject: RE: [JSF] Tiles and Reusable Template


I looked at Clay and it looks like it will work but I want to examine
facelets more first.

The facelets tutorial says it does easy templating but there were no
examples on how to do it and I couldn't find one in the documentation.
Is there an example of this somewhere?


Shawn
-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Laurie Harper
Sent: Wednesday, February 22, 2006 6:44 PM
To: users@myfaces.apache.org
Subject: Re: [JSF] Tiles and Reusable Template

Garner, Shawn wrote:
> I tried using tiles with JSF and found it does not work very well.
> 
> You end up having to define every page in the tiles.xml file that you
want
> to use the template for.
> 
> Are there any other approaches to creating a reusable template that
uses
> multiple jsp pages?
> 
> Seems like I should be able to just include a page and override the
body,
> title portion without redefining the template for every page.

You may be able to do what you want with Tiles using the JSP tags 
instead of the XML file. Alternatively, take a look at Facelets or Shale

Clay.

L.

************************************************************************
**** 
This email may contain confidential material. 
If you were not an intended recipient, 
Please notify the sender and delete all copies. 
We may monitor email to and from our network. 
************************************************************************
****

************************************************************************
**** 
This email may contain confidential material. 
If you were not an intended recipient, 
Please notify the sender and delete all copies. 
We may monitor email to and from our network. 
************************************************************************
****

************************************************************************
**** 
This email may contain confidential material. 
If you were not an intended recipient, 
Please notify the sender and delete all copies. 
We may monitor email to and from our network. 
************************************************************************
****

**************************************************************************** 
This email may contain confidential material. 
If you were not an intended recipient, 
Please notify the sender and delete all copies. 
We may monitor email to and from our network. 
****************************************************************************

Mime
View raw message