Solved

Tag Tiles

Posted on 2006-11-11
6
334 Views
Last Modified: 2013-11-19
Hi,
I have read this article about Tiles, but I just can't understand the use of it.

http://www.onjava.com/lpt/a/2834

Here it creates the layout :
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles"%>
<html:html>
 <head>
  <title><bean:message key="global.title"/></title>
  <html:base/>
 </head>
 <body topmargin="0" leftmargin="0" bgcolor="#FFFFFF">
  <tiles:insert attribute="header"/>
  <tiles:insert attribute="menubar"/>  
  <tiles:insert attribute="body-content"/>
  <tiles:insert attribute="copyright"/>
 </body>
</html:html>

Then the JSP index.jsp using the layout :
<%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>
<tiles:insert page="/layouts/storefrontDefaultLayout.jsp" flush="true">
  <tiles:put name="header" value="/common/header.jsp" />
  <tiles:put name="menubar" value="/common/menubar.jsp" />
  <tiles:put name="body-content" value="/index-body.jsp" />
  <tiles:put name="copyright" value="/common/copyright.jsp" />
</tiles:insert>


It says the following about the advantage of the layout file :

>> This one file can then control the layout of multiple pages.
>> If we need to modify the layout of the site,
>> this is the only file we need to change--that's the real power of using a template-based approach.

But I don't understand how I can modify the layout of the site with just that file !!
Layout is in CSS, I use include of jsp in my website

>> Although the include mechanism is a step in the right direction because it does reduce redundancy
>> (imagine if we included the copyright content in every page!),
>> it's still less efficient than a template-based approach.
0
Comment
Question by:matthew016
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 10

Expert Comment

by:jaggernat
ID: 17921168
layout is like a placeholder in which you can place different jsp pages. go through this link, it explains very clearly

http://www-128.ibm.com/developerworks/websphere/library/techarticles/0311_fung_yu/fung_yu1.html
0
 
LVL 9

Author Comment

by:matthew016
ID: 17921450
Well,
I still have the same questions,

See: let's say I want to change the layout of my website (http://www.lehall.org)
the menu of the left, I want to move it to the right
(that's why the template is for, right ? changing layout easily)

Well I will still need to change the CSS of all my body contents !!
(because in those css I have a big left margin so that it content is displayed to the left of the menu, u follow?)
So I will have to change all the css for the body, and also define the new margin of the menu so that it can be displayed to the right of the body !

Do u understand what I don't get ?
0
 
LVL 14

Assisted Solution

by:boonleng
boonleng earned 200 total points
ID: 17924218
To change the position of the layout (eg. menu from left to right), it can be done just changing CSS.
But to change the design of the layout (eg from 1 columns to 3 colums layout), then the template will come it useful as it will apply to all the pages speficy in th configuration file. Without that you will need to modify every pages.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Accepted Solution

by:
jaggernat earned 300 total points
ID: 17926879
well, css in the body and the layout are totally independent of each other.
Say for instance you have 10 pages which have menu on the left and 10 pages with menu on the right. Then what you do is define two layout jsps, one with menu on the left(leftmenulayout.jsp)and the other layout with menu on the right(rightmenulayout.jsp).
10 pages with menu on the left use leftmenulayout.jsp and 10 pages with menu on the right use rightmenulayout.jsp.
what kind of a layout does a jsp use is defined in a single xml file(called tiles-def.xml). so you dont have to use layout indivudually in each jsp and that is why things become so easier.

in your case i would suggest, create a layout with menu on the right and modify the css in your body accordingly.



0
 
LVL 9

Author Comment

by:matthew016
ID: 17929101
So I would have a css for the layout itself,

I will have two kind of css :
css for layout specific  (layout_model_1.css)
css for content specific (menu.css, content.css, footer.css, ...)
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17930028
yes
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question