?
Solved

Tag Tiles

Posted on 2006-11-11
6
Medium Priority
?
338 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 800 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
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 
LVL 10

Accepted Solution

by:
jaggernat earned 1200 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Suggested Courses

762 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