Solved

Tag Tiles

Posted on 2006-11-11
6
335 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
Independent Software Vendors: 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

696 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