Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

Search: 

  Tutorial: UI design with Tiles and Struts

UI design with Tiles and Struts

Tutorial Details:

UI design with Tiles and Struts
UI design with Tiles and Struts
By: By Prakash Malani
Several solutions for organizing your HTML and JSP view components
ypically during Web application development, the user interface (UI) group creates the site's look and feel. Based on that look and feel, the group creates HTML pages that represent the application's functionality and navigation. With a servlets and JavaServer Pages (JSPs)-based implementation, where HTML pages are converted into servlets and JSPs, UI developers identify common HTML and JSP view components, such as header, footer, body, menu, and search. This article presents various solutions to effectively and efficiently organize HTML and JSP view components. I evaluate each solution using specific criteria, such as page number, code repetition, and layout control.
To explore templating and layout solutions, we will use the Tiles framework. The Tiles framework's view components are known as tiles . The framework uses an XML configuration file to organize those tiles. This framework not only enables you to reuse tiles, but also the layouts that organize them.
To explore the more powerful and flexible solutions, we will investigate the synergy between the Tiles and Struts frameworks. Struts is an open source framework for developing Web applications using the popular Model-View-Controller (MVC) or Model 2 architectural pattern. Struts comes with a large set of reusable tags for which the Tiles tag library makes an excellent enhancement.
Evaluation criteria
I will evaluate each solution based on the criteria below. The criteria are not mutually exclusive. For a specific situation and particular application, you must always balance between the strengths and weaknesses of each solution with respect to these factors.
Page number
A solution should strive to minimize the number of HTML and JSP pages. As the page number increases, the complexity of developing, managing, and maintaining an application increases drastically.
Code repetition
Under most circumstances, repetition is bad. The more repeated HTML and JSP code, the more difficult it is to develop and maintain an application. A simple change can result in a cascade of changes in many different pages with unpredictable consequences. A concrete and practical way of attaining reuse is to avoid code repetition.
Layout control
While code repetition is bad, repetition of layout logic and code can be worse. Spreading the logic and behavior of view component organization over several JSPs can be a recipe for disaster. Attaining reuse of templating and layout logic is a better form of reuse than only reusing view components. Thus, you can achieve a higher level of reuse with effective layout control.
Coupling
Coupling is the degree of interactivity between entities. Software engineers are taught again and again to minimize coupling between unrelated classes, packages, and so on. We can apply the same principle to view components. Even though there are distinct view components from a user perspective, in the JSP implementation, the components might be intricately coupled. A solution should reduce coupling between unrelated view components.
Complexity
Complexity brings increased development and maintenance costs, making a more complex solution less suitable. Complexity grows fast as well, and what might originally look simple and innocuous can quickly turn into a big mess as you add more pieces.
Solutions
I'll evaluate several solutions using a basic example of JSPs with common view components, like header and footer. I'll present these solutions in order of increasing complexity, and then I'll measure in detail each one against the evaluation criteria.
Solution 1: Basic JSP
Consider the following JSP for a.jsp :


Header


a's body...


Footer




Consider the following JSP for b.jsp :


Header


b's body...


Footer




In many cases, the developers obtain the code from the UI group and literally convert it into a JSP as necessary. As shown above, each JSP has a duplicate header and footer. Solution 1 is undesirable because changes in common view components, like header and footer, require changes in all relevant pages, as each page is responsible for laying out the view components. This simple solution lacks foresight. With so much HTML and JSP code duplication, we minimize the number of pages but at a heavy maintenance cost. There is strong coupling between the different view components, which, as I explained earlier, is undesirable.
Solution 2: JSP include
Consider the following JSP for a.jsp :


<%-- include header --%>

a's body...


<%-- include footer --%>



Consider the following JSP for b.jsp :


<%-- include header --%>

b's body...


<%-- include footer --%>



Note that common view components, like header and footer, are split up using the JSP include mechanism.
Consider this header.jsp :
Header


Consider this footer.jsp :
Footer


Solution 2 nicely addresses some of Solution 1's major shortcomings. You only need to change common view components once. Hence, this solution greatly eliminates HTML and JSP code repetition, significantly improving application maintainability. It increases the page number a bit, but drastically reduces the tight coupling between common view components and other pages. On the complexity scale, this solution is simple and readily implemented on many real-world applications. However, it has one major drawback: if you change how and where you organize the view components (i.e., by changing the component layout), then you would need to update every page -- resulting in an expensive and prohibitive change. Solution 2 achieves view component reuse, but does not achieve the reuse of layout and templating logic.
Solution 3: Tiles insert
Consider this JSP for a.jsp :
<%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>


<%-- include header --%>

a's body...


<%-- include footer --%>



Consider this JSP for b.jsp :
<%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>


<%-- include header --%>

b's body...


<%-- include footer --%>



Instead of using the JSP include mechanism, Solution 3 uses the Tiles insert mechanism. Using the Tiles insert tag, you include the view components in the appropriate positions. In all other aspects, the solution mirrors the JSP include solution (Solution 2) exactly, with the same advantages and disadvantages.
Solution 4: Splitting bodies
Consider this a.jsp :
<%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>


<%-- include header --%>

<%-- include body --%>

<%-- include footer --%>



Consider this b.jsp :
<%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>


<%-- include header --%>

<%-- include body --%>

<%-- include footer --%>



Solution 4 differs slightly from the Tiles insert solution. Solution 4 separates the core bodies into their individual pages, like aBody.jsp and bBody.jsp .
Consider the following JSP for aBody.jsp :
a's body...


Consider the following JSP for bBody.jsp :
b's body...


Solution 4's advantage: it limits body changes to the respective pages. Also, it lets you reuse the bodies in other places, eliminating the need for repetition and duplication. Thus, the solution further diminishes the coupling between common view components and other application components. Creating and managing each body component introduces an additional complexity level. As with other solutions, each page still does its own layout. Hence, there is no overarching layout policy or scheme.
Solution 5: Templating tiles
Using Tiles's templating feature, you can define the following layout (from the layout.jsp file shown below) as a template. Since this is a layout, you insert placeholders instead of the actual view components using the Tiles insert tag. Thus, for all components, this page defines one reusable layout:
<%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>


<%-- include header --%>

<%-- include body --%>

<%-- include footer --%>



Other content pages, like a.jsp and b.jsp , use the above layout for arranging components. In the actual page, you insert the layout using the Tiles insert tag. Using the Tiles put tag, you can specify the actual view components for all placeholders specified in the layout.
Consider this a.jsp :
<%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>





Consider this b.jsp :
<%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>





Solution 5's most significant advantage is that it encapsulates the layout sche


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
UI design with Tiles and Struts

View Tutorial:
UI design with Tiles and Struts

Related Tutorials:

Displaying 1 - 50 of about 636 Related Tutorials.

Developing Simple Struts Tiles Application
Developing Simple Struts Tiles Application Developing Simple Struts Tiles Application     ... In this section  I will show you how to develop simple Struts Tiles Application
 
Developing Simple Struts Tiles Application
Developing Simple Struts Tiles Application Developing Simple Struts Tiles Application     ... In this section  I will show you how to develop simple Struts Tiles Application
 
Using tiles-defs.xml in Tiles Application
the Tiles plugin in struts-config.xml file.  Add the following code.../struts/dtds/tiles-config_1_1.dtd"> <tiles-definitions... the Struts Action to use Tiles Definition Open the struts-config.xml file and add
 
Using tiles-defs.xml in Tiles Application
the Tiles plugin in struts-config.xml file.  Add the following code.../struts/dtds/tiles-config_1_1.dtd"> <tiles-definitions... the Struts Action to use Tiles Definition Open the struts-config.xml file and add
 
Struts Tutorials
topics like Tiles, Struts Validation Framework, Java Script validations... cancel button and a few other design issues with Struts Action classes. Ok, let?s get...-Controller (MVC) design paradigm. Most Struts applications use a browser
 
Struts IDEs
. With the Struts Console you can visually edit JSP Tag Library, Struts, Tiles... Struts IDEs Struts IDEs Easy Struts for Eclipse / Jbuilder The Easy Struts project provides plug-ins
 
Struts IDEs
. With the Struts Console you can visually edit JSP Tag Library, Struts, Tiles... Struts IDEs Struts IDEs Easy Struts for Eclipse / Jbuilder The Easy Struts project provides plug-ins
 
Struts Reference
to the MVC design pattern Struts Validation framework with example Struts Tiles... Struts Reference,Online Reference Struts,Jakarta Struts Reference,Reference Struts Struts Reference Welcome
 
Struts Tutorials - Jakarta Struts Tutorial
. In struts JavaServerPages (JSP) are used to design the dynamic web....    Developing Application with Struts Tiles In this lesson we will create Struts Tiles Applications.  
 
Struts Links - Links to Many Struts Resources
in the pdf format. Practical Java Design with Struts and JDO WebEmp is one... and Web worlds: HTML, JavaScript, CSS, Struts, JSP, Java, Object Oriented Design and JDO into a practical and affordable design.Practical Java Design with Struts
 
Struts Links - Links to Many Struts Resources
in the pdf format. Practical Java Design with Struts and JDO WebEmp is one... and Web worlds: HTML, JavaScript, CSS, Struts, JSP, Java, Object Oriented Design and JDO into a practical and affordable design.Practical Java Design with Struts
 
Struts Tutorials
topics like Tiles, Struts Validation Framework, Java Script validations... cancel button and a few other design issues with Struts Action classes. Ok, let?s get...-Controller (MVC) design paradigm. Most Struts applications use a browser
 
Struts Console
applications. With the Struts Console you can visually edit Struts, Tiles and Validator... support for Struts 1.0 - 1.2 config files Full support for Tiles config... Struts Console Struts Console
 
Struts Alternative
applications based upon the Model-View-Controller (MVC) design paradigm. Most Struts... Struts Alternative Struts Alternative Struts is very robust and widely used framework, but there exists
 
Struts Books
, and internationalization and flexibility of design are deeply rooted. Struts uses the Model... design can lead to long term dependencies on the Struts framework, which makes... is a comprehensive introduction to the Struts framework. It covers initial design
 
Struts Book - Popular Struts Books
to design, build, and deploy sophisticated Struts 1.1.This book covers... introduction to the Struts framework. It covers initial design, data validation..., and internationalization and flexibility of design are deeply rooted. Struts uses the Model-View
 
Welcome to the Apache Struts Tutorial
. In struts JavaServerPages (JSP) are used to design the dynamic web....    Developing Application with Struts Tiles In this lesson we will create Struts Tiles Applications.  
 
Beginner to advance guide to the Apache Struts
. In struts JavaServerPages (JSP) are used to design the dynamic web....    Developing Application with Struts Tiles In this lesson we will create Struts Tiles Applications.  
 
Struts-It
1.1, 1.2 and JSTL. Key Features Fully Support for Struts 1.1 and 1.2, Tiles... Struts-It Struts-It  ...;            Struts
 
Jakarta Struts & Advanced JSP Course
Jakarta Struts & Advanced JSP Course Jakarta Struts & Advanced JSP Course      ...;        Jakarta Struts Training
 
Struts Book - Popular Struts Books
to design, build, and deploy sophisticated Struts 1.1.This book covers... introduction to the Struts framework. It covers initial design, data validation..., and internationalization and flexibility of design are deeply rooted. Struts uses the Model-View
 
Struts 2 Tags (UI Tags) Examples
Struts 2 Tags,Struts 2 Tags Reference,Struts 2 UI Tag,Struts 2 UI Tags Struts 2 Tags (UI Tags) Examples    ... are going to describe the checkbox tag. The checkbox tag is a UI tag
 
Struts Software
enterprise wide within Business Analyst design tools Struts Console he Struts... Library, Struts, Tiles and Validator configuration files. The Struts Console.... Visually design, implement, and maintain web pages for JSTL and Struts-based web
 
Struts Software
enterprise wide within Business Analyst design tools Struts Console he Struts... Library, Struts, Tiles and Validator configuration files. The Struts Console.... Visually design, implement, and maintain web pages for JSTL and Struts-based web
 
How Struts Works
. In struts JavaServerPages (JSP) are used to design the dynamic web pages. In struts... applications easier to design, create, and maintain. Struts is purely based... How Struts Works, How Struts Work,Working of Struts
 
Actionerror and Actionmessage Tags (Non-Form UI Tags) Example
Struts 2 Tags,Struts 2 Tags Reference,Struts 2 Non-Form UI Tags,Struts 2... Actionerror and Actionmessage Tags (Non-Form UI Tags) Example    ... is a UI tag that renders action errors (in the jsp pages.) if they exists while
 
Easy Struts
on the MVC design pattern provided by the Jakarta Struts framework. Easy Struts... Easy Struts Easy Struts...;         The Easy Struts project
 
Struts Guide
is the implementation of Model-View-Controller (MVC) design pattern for the JSP. Struts... Struts Guide Struts Guide...; This tutorial is extensive guide to the Struts Framework. In this tutorial you
 
Struts 2.0.5 Released
in Struts 2 applications.. o Tiles Plugin - A new plugin allows your Struts actions to return Tiles pages. The Tiles plugin is dependant on Tiles 2... Struts 2.0.5,Struts 2.0.5 Released,Struts 2.0.5 Download
 
Struts 2.0.4 Released
and ActionForms in Struts 2 applications.. Tiles Plugin- A new plugin allows your Struts actions to return Tiles pages. The Tiles plugin... Struts 2.0.4,Struts 2.0.4 Released Struts 2.0.4
 
Struts Guide
is the implementation of Model-View-Controller (MVC) design pattern for the JSP. Struts... Struts Guide Struts Guide...; This tutorial is extensive guide to the Struts Framework. In this tutorial you
 
Struts 2 Tutorials for Beginners, Struts 2 Tutorial
of the stack if none is specified. Struts 2 Tags (UI Tags) Examples   ... Struts 2 Tutorial,Struts2 Examples,Apache Struts 2 Tutorials - Free Java Programming Tutorials Struts 2 Tutorial  
 
Introduction to Struts 2 Tags
    Struts UI tags Struts UI Tags are mainly designed... by templates and themes.  Struts UI Tags are of two types Form Tags and Non... Struts 2 Tags Struts 2 Tags   
 
Developing Struts PlugIn
for struts e.g. Struts Tiles PlugIn, Struts Hibernate PlugIn, Struts Spring PlugIn... Developing Struts PlugIn,Struts PlugIn,Struts PlugIn Example Developing Struts PlugIn   
 
What is Struts - Struts Architecturec
Struts Architecture,Struts Architectures What is Struts - Struts Architecture     ... will discuss about Architecture. Struts is famous for its robust Architecture
 
Struts 2 - History of Struts 2
Struts 2 History Struts 2 History   ...;            Apache Struts... taken over by the Apache Software Foundation in 2002. Struts have provided
 
Struts 1.x Vs Struts 2.x
Struts 1 Vs Struts 2,Struts 2. Vs Struts 1,Struts 1.x Vs Struts 2.x Struts 1.x Vs Struts 2.x      ... are going to compare the various features between the two frameworks. Struts 2.x 
 
Struts 2.0.9 Released
Struts 2.0.9,Struts 2.0.9 Released,Struts 2.0.9 Download,Struts 2 download Struts 2.0.9 Released     ... is pleased to announce the release of Struts 2.0.9 with many bug fixes
 
Downloading Struts & Hibernate
-examples.war, struts-mailreader.war and tiles-documentation.war files... Downloading Struts & Hibernate,downloading Struts,Downloading Hibernate,Setup Hibernate,Setup Struts Downloading Struts
 
Fielderror Tag (Non-Form UI Tags) Example
Struts 2 Tags,Struts 2 Tags Reference,Struts 2 Non-Form UI Tags,Struts 2 UI Tags,Fielderror Tag Fielderror Tag (Non-Form UI Tags.... The fielderror tag is a UI tag that renders field errors if they exists.  Add
 
Jakarta Struts Interview Questions
of application of any size. Struts framework makes it much easier to design scalable... Jakarta Struts Interview Questions Jakarta Struts...;       Q: What is Jakarta Struts
 
Struts 2 Tutorial
of the stack if none is specified. Struts 2 Tags (UI Tags) Examples   ... Struts 2 Tutorial,Struts2 Examples,Apache Struts 2 Tutorials - Free Java Programming Tutorials Struts 2 Tutorial  
 
Why Struts 2
New Features of Struts,Features of struts 2,Why Struts 2 Why Struts 2          ...;    The new version Struts 2.0 is a combination
 
Why Struts 2
New Features of Struts,Features of struts 2,Why Struts 2 Why Struts 2          ...;    The new version Struts 2.0 is a combination
 
Open Source Web Frameworks in Java
with component orientated design GUI programming.  Struts (like other Model II... Open Source Web Frameworks in Java Struts Struts Frame work is the implementation of Model-View-Controller (MVC) design pattern for the JSP
 
Struts Interview Questions
of Struts? Answer: Struts is based on the MVC design pattern. Struts components... Struts Questions,Struts Interviw,Struts Interview Questions Struts Interview Questions    
 
Jump Start UI for Eclipse
Jump Start UI for Eclipse Jump Start UI for Eclipse...;      Jump Start UI is a development tool that literally jumpstarts your UI desigining process by generating initial display
 
Separating UI from Logic
Java: Separating UI from Logic Java NotesSeparating UI from Logic One of the most important ideas in organizing programs is to separate the user interface (GUI, presentation, view
 
Actionerror and Actionmessage Tags (Non-Form UI Tags) Example
Struts 2 Tags,Struts 2 Tags Reference,Struts 2 Non-Form UI Tags,Struts 2... Actionerror and Actionmessage Tags (Non-Form UI Tags) Example    ... is a UI tag that renders action errors (in the jsp pages.) if they exists while
 
Eclipse Plunging/UI
Eclipse Plunging/UI Eclipse Plunging/UI...;     Mylyn Mylyn is a Task-Focused UI for Eclipse... UI on the interesting information, hide the uninteresting, and automatically
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.