Solved

Tag Tiles

Posted on 2006-11-11
6
332 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
  • 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

776 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