wood burning stoves 2.0*
The moose likes Struts and the fly likes Tiles in struts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Tiles in struts?" Watch "Tiles in struts?" New topic
Author

Tiles in struts?

amith amith
Greenhorn

Joined: Oct 26, 2006
Posts: 7
Hi all,
i am working on tiles,i did a sample application on tiles just to display all other pages from a template page,it worked.but now i have a left menu in a layout where i have given links(hrefs) to all other pages.if i click on the links ,its working fine but it will not display in layout.whether i have to use putList or what?please explain to change contents(pages)in an application using my left menu options(ie, hrefs).
please post reply.
THANKS IN ADVANCE
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
I'm not sure what the question really is, by I'll try to help.

Lets say you want an application with a left hand navigation and to the right of that will be the body. Well to make it more realistic we'll throw a header and a footer in the mix.

siteLayout.jsp


Now for the tile definitions. Note that the header and navigation are generated dynamically, so they will reference a .do, the footer is static content, so it will reference the JSP.

tiles-defs.xml:


link1 and link2 are dynamically generated, so the action will point to a reference in the struts-config.xml and that will in turn point to the tile-defs.xml to reference its JSP.

struts-config.xml snippet:


I'm not sure if that's what you were looking for, but hope it helps.

-Chris
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

"Amith BN",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. Initials for a last name are not acceptable.

Thanks!
bear
JavaRanch Sheriff
[ November 10, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
amith amith
Greenhorn

Joined: Oct 26, 2006
Posts: 7
hi chris,
Thanks for the example,but the thing is that i am using(<tiles:insert definition="index.page" /> in Jsp page to include the content.
in detail:
1>i have a left navigation where i have given 4 href to go to other pages like addemployee,listemployee,designation....etc
2>my template look like this

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<html>
<table border="1" cellpadding="0" cellspacing="0" width="100%" height="100% bordercolor="#000000" bgcolor="#E7FDFE">
<tr>
<td width="100%" colspan="2" valign="top"><tiles:insert attribute="header"/></td>
</tr>
<tr>
<td width="23%" valign="center" ><tiles:insert attribute="navigation"/></td>
<td width="77%" valign="top" ><tiles:insert attribute="body"/></td>
</tr>
<tr>
<td width="100%" colspan="2" valign="top"><tiles:insert attribute="bottom"/></td>
</tr>
</table>
</html>

3>my tiles-defs.Xml look like this

<?xml version="1.0" encoding="ISO-8859-1" ?>

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

<tiles-definitions>
<definition name="example" page="/template.jsp">
<put name="header" value="/header.jsp" />
<put name="body" value="body.do"/>
<put name="navigation" value="/navigation.jsp" />
<put name="bottom" value="/footer.jsp" />
</definition>

<definition name="index.page" extends="example" >
<put name="body" value="/Department.jsp" />
</definition>
</tiles-definitions>
MY PROBLEM IS:
i am getting tiles layout with navigation,header,footer,body(simple static page),but when i click on the link(hrefs) i am getting my content(Department.jsp) displayed outside the layout.


HELP ME CHRIS>>>>>>>>>>>>>
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

"Amith B.N"

Your name is still not correct. Please correct it right away to avoid account suspension.

-Scott


My Blog: Down Home Country Coding with Scott Selikoff
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
Each linked page you're going to should have its own definition.

IE:


Also, looking at index.page I see something that may be a problem. In the base definition (example) to add body with a value. Then in index.page you give body a value, while at the same time inheriting a body value from example. You are going to be specifying a different body in each page, so I would pull it out of the base def..you'll have to make changes to your struts-config more than likely when you do this as well.

Hope it helps,
Chris

PS,
Like they say, you're going to have to change your name to something that looks like a real full name. This is a great community for getting help and it's about the only rule enforced.
[ November 13, 2006: Message edited by: Chris Boldon ]
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

"Amith"

Please review our naming policy one more time. In particular, names must be made up of a first name or initial followed by a last name.

-Scott
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

"amith amith"

Your name still does not conform to our naming policy. You have been warned 3 separate times before and this is your final warning.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

"amith amith",

Your account has been disabled. Should you wish to reinstate your account please contact me via email.

bear
JavaRanch Sheriff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tiles in struts?
 
Similar Threads
Interesting tiles/struts making a menu question
State management
Tiles Question - howto solve variety body ?
Frameset Refresh Problem
Tiles: how to refresh just one tile?