The moose likes Struts and the fly likes Tiles template Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Struts
Reply Bookmark "Tiles template" Watch "Tiles template" New topic
Author

Tiles template

Rashid Darvesh
Ranch Hand

Joined: Feb 13, 2004
Posts: 189
i have a simple question.
i have a default template DefaultLayout.jsp with the following
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<html>
<body>
<tiles:insert attribute="header"/>
<tiles:insert attribute="left"/>
<tiles:insert attribute="body"/>
<tiles:insert attribute="footer"/>
</body>
</html>
and in the index.jsp page i used somethinglike this
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<tiles:insert page="/DefaultLayout.jsp" flush="true">
<tiles ut name="header" value="/Header.jsp" />
<tiles ut name="left" value="LeftBar.jsp" />
<tiles ut name="body" value="/Customer.jsp" />
<tiles ut name="footer" value="/Footer.jsp" />
</tiles:insert>
Now i have a login.jsp file taht has two elements user name text field and pasword text field. So when i click on the login hyperlink how can i put Login.jsp in the body instead of customer. its a bit confusing. Where should i define the tiles put tag where the body is set to Login.jsp
I hope i am clear in stating the problem
Thanks
Kim Lilienfeld
Greenhorn

Joined: Apr 13, 2004
Posts: 25
Hi There

You need to create a tiles-defs.xml which will look something like this

<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config.dtd">

<tiles-definitions>

<definition name="first_page" path="/DefaultLayout.jsp">
<put name="header" value="/Header.jsp"/>
<put name="left" value="/LeftBar.jsp"/>
<put name="body" value="/Customer.jsp"/>
<put name="footer" value="/Footer.jsp"/>
</definition>

</tiles-definitions>

Now what you want to do is add a new definition, so below </definition> you should add the following:

<definition name="login" extends="first_page" path="/DefaultLayout.jsp">
<put name="body" value="/Login.jsp"/>
</definition>

Which basically means you are extending first_page (The one i declared first) but are replacing the body with Login.jsp.

Hope this helps.
Kim
 
 
subject: Tiles template
 
Threads others viewed
tiles XML definition help
Problem With Tiles
How tiles are resolved in a JSP page
Struts error
nested tiles
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture