Solved

Tag Tiles

Posted on 2006-11-11
6
329 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 10

Accepted Solution

by:
jaggernat earned 300 total points
Comment Utility
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
Comment Utility
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
Comment Utility
yes
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now