The i-Technology Media!
Register | Log in
   
 
.NET  ·  AJAX  ·  CLOUD  ·  ECLIPSE  ·  FLEX  ·  OPEN WEB  ·  iPHONE  ·  JAVA  ·  LINUX  ·  OPEN SOURCE  ·  ORACLE  ·  PBDJ  ·  SEARCH  ·  SILVERLIGHT  ·  SOA  ·  VIRTUALIZATION  ·  WEB 2.0  ·  WIRELESS  ·  XML
Comments
Drool, Britannia? Is the UK Failing the Cloud?
By Roger Strukhoff
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Jan. 8, 2012 11:38 AM EST
read more & respond »
Cloud Expo on Google News
Did you read today's front page stories & breaking news?

Cloud Expo & Virtualization 2011 West
Keynotes
Oracle
Opening Keynote | An Enterprise Cloud for Business-Critical Applications
Abiquo
Day 2 Keynote | The Enterprise Cloud Tightrope - Balancing for Success
Akamai
Day 3 Keynote | The DNA of an Enterprise Cloud
DIAMOND SPONSOR:
Oracle
Many Clouds, Many Choices'Cloud
PLATINUM PLUS SPONSORS:
Abiquo
Enterprise Cloud Best Practices - Town Hall - Join the discussion…
PLATINUM SPONSORS:
Intel
Progressing Toward the Federated, Automated and Client-Aware Cloud
New Relic
How to build an app with Twitter-like throughput
Rackspace
Computing in the Cloud Era
GOLD SPONSORS:
Gale Technologies
Practical Cloud Migration
IBM
Re-think IT. Re-inventing Business.
Intel/McAfee
Identity Driven Security in the Cloud
PerspecSys
Hackers Hackers Everywhere, Is My Public Cloud That Safe?
Red Hat
Unlock the Value of the Cloud
SHI
Mission Critical Applications and the Cloud - Myth or Reality?
SoftLayer
Not Your Grandpa's Cloud
Terremark
Integrating Enterprise Clouds
VMware
Upgrade to a vCloud
POWER PANELS:
Cloud Expo Silicon Valley: CTO Power Panel
Cloud Expo Silicon Valley: CEO Power Panel
Cloud Expo Silicon Valley: Cloud SuperStars Panel
Cloud Expo Silicon Valley: CloudNOW Panel
Click For 2010 West
Event Webcasts
Cloud Expo & Virtualization 2011 East
DIAMOND SPONSOR:
Dell
Dell & VMware Deliver the Enterprise Hybrid Cloud
PLATINUM PLUS SPONSORS:
Abiquo
Are Financial Services Organizations Risking Security by Avoiding Cloud Computing?
Oracle
From Consolidation to Enterprise Private PaaS
PLATINUM SPONSORS:
Intel
Driving the Transformation to Next Generation Cloud Data Centers
Rackspace
The Inevitability of an Open Cloud
GOLD SPONSORS:
CA Technologies
Follow YOUR path to Cloud Computing
Interxion
Who Keeps the Cloud in the Air?
Microsoft
Patterns for Cloud Computing
PerspecSys
War in the Clouds: Are you ready?
ServiceMesh
The Big Win: Stop Playing Small-Ball with Your Cloud Strategy
Terremark
Evaluating Enterprise Clouds
Xiotech
Cloud Storage: Myths and Realities
POWER PANELS:
Cloud Expo New York: CTO Power Panel
Cloud Expo New York: CEO Power Panel
Cloud Expo New York: CMO Power Panel
Cloud Expo New York: Wrap-Up Power Panel
Click For 2010 West
Event Webcasts
Live Google News by SYS-CON!
Top Three Links You Must Click On


Feature
Creating Reusable Visual Components
Creating Reusable Visual Components

By: George M. Pieri
Aug. 27, 2003 12:00 AM

Creating Web pages with HTML can be time consuming, so it's critical to create generic visual components that can easily be reused. This will give you a consistent look and feel throughout your application. You'll be able to add new functionality at one location and make it available across multiple Web pages, which can save you a lot of time.

Creating Reusable Visual Components
In order to create reusable visual components, it's important to create generic stylesheets and JavaScript routines. The stylesheets can be used to display tabular data in a grid format, or menus to navigate your Web application (e.g., WebGrid.xsl, WebMenu.xsl). Even though these examples will show you how to build reusable tabular pages and menus, the same ideas can be used to generate any common type of Web page.

The reusable stylesheet to display tabular (grid) data, WebGrid.xsl, should:
1.  Read instructions on how to build the view, defined between <VIEW> </VIEW> tags
2.  Read the XML data, defined between <DATA></DATA> tags, and transform it to HTML using XSL

The instructions on how to build the view are represented as XML. These build instructions, along with the XML data, are used by the generic stylesheet, WebGrid.xsl, to develop the HTML page. An example of the build instructions to generate a Web page with tabular data is shown in Listing 1.

In this example we have one visual component, a grid, defined. It will display two columns, Name and Phone, which are mapped to the XML data that we read, and shown between the start and end DATA tags. The end user will be able to add, delete, or refresh data by clicking on buttons (see Figure 1).

A portion of the XML data that is transformed by the build instructions and grid stylesheet processor is shown in Listing 2.

Creating a Reusable Grid
WebGrid.xsl, the generic stylesheet that builds the grid, can read all the configuration values from the Visual XML information as defined between the VIEW tags. Since a grid is an HTML table structure, it will dynamically read all the table attributes, such as the grid style, and dynamically assign them to our table. It will also read which columns we should display and show their values by calling the DefineFieldNames template shown in Listing 3.

The DefineFieldNames template is executed as the HTML Web page is being generated. Its main purpose is to see which fields should be displayed on the grid. Dynamically figuring out which columns should be displayed allows WebGrid.xsl to be used for different Web pages with different result sets as long as the columns are defined in the view XML.

<!-DYNAMICALLY SEE WHICH FIELDS TO DISPLAY -->

<xsl:template match="//VIEW/GRID/COLUMNS/COLUMN"
mode="DefineFieldNames">
<td><xsl:value-of select="@fieldname" /></td>
</xsl:template>

Many other grid characteristics can be set dynamically as well. Each characteristic should be defined as an attribute, and then the generic stylesheet will read this attribute at runtime and decide what to set. Some other characteristics you can set for each column/cell in your grid are shown below:

<COLUMN
alignment="left" visible="T"
editable="T" objecttype="0"
onclickfunc="" onblurfunc="" on
changefunc="ClientOnChangeData()"
maxlength="" size="145px"/>

You can then process these attributes in templates in your XSL file as shown. This will set the alignment of the text in the cell as defined for the specific column in the view XML.

<!-DYNAMICALLY SET ALIGNMENT of EACH GRID CELL -->

<xsl:template
match="//VIEW/GRID/COLUMNS/COLUMN"
mode="CreateDataRows">
<td>
<xsl:attribute
name="align">
<xsl:value-of select
="@alignment"/>
</xsl:attribute>
.
</xsl:template>

Advantages of visual XML
Representing your grid with visual XML has many advantages. It enables you to add a new column and within minutes have it automatically show up on the grid. No longer do you have to modify the HTML and then make sure that everything lines up correctly. The entire color of the grid, along with fonts and many other attributes, can be changed by simply modifying the view XML. It's also easy to identify what columns are used for which screens, and it makes modifications quick.

Creating a Reusable Menu
The instructions on how to build the menu are defined using XML, just like with the grid. These build instructions are processed by the generic stylesheet, WebMenu.xsl, to develop the Web page with the menu. A sample of the build instructions to generate the menu is shown in Listing 4.

In this sample we have one visual component, a menu, defined. It will display a pulldown menu for your Web pages. Each menu item can have a custom dropdown submenu. For the Reports menu item there are two dropdown choices, Show Customers and Show Countries, which will each display a different report. The PROCESSOR tag and ACTION tag can be used to direct the client-side request to a server-side servlet to process it. The ACTION represents the specific item that the end user wants done.

Generating the Menu
WebMenu.xsl, which builds the menu, can read all the configuration values from the visual XML information just like we did with the grid control. A template can be used to read through the view XML and process the information to build the menu. The XSL code snippet shown in Listing 5 illustrates how to examine the XML.

Advantages of view XML
Representing your menu with view XML has advantages. It enables you to add a new dropdown menu item without modifying any HTML code. You can also quickly change the menu structure. This method provides one central location that all developers can look at to see which back-end processors are being used by the front-end interface, without having to examine HTML.

Conclusion
Using XML you can describe what kind of visual components you would like to have on your Web pages. This allows your stylesheets to be reusable since no hard-coded XML column names or attributes appear within them. This allows you to change your view without having to directly modify your HTML or JavaScript code. This approach can greatly reduce your development time and allow you to become more efficient at making modifications for the ever-changing world of user requirements.

Published Aug. 27, 2003— Reads 9,652
Copyright © 2003 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
Related Links
▪ Source Code
About George M. Pieri
George M. Pieri is a senior system architect and developer and has
worked at IBM.He has been doing Web and object-oriented development
for the last seven years. George can be reached at gmpweb@hotmail.com.

Add Your Feedback

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers

ADS BY GOOGLE

Breaking Java News
Veramark to Announce Fourth Quarter Results and Hold Conference Call
The Buller Group, LLC Partners and Signs Teaming Agreement With Caspian Global
Harper Government Invests in Health of Dairy Herds
Country Music Star Trace Adkins to Serve as Spokesperson for Pilot Flying J, the Driver-Driven Company
Western Barley Growers Welcome Marketing Freedom
Sentara Healthcare Chooses EXTENSION Clinical Alerting Solutions for Nurses
New Position Will Help Train Properties To Become Model Hotels
GrayHair Software Announces First-of-Its-Kind Guarantee Service
US SIF Appoints Managing Partner of New Amsterdam Partners to Board of Directors
Permian Basin Royalty Trust Announces February Cash Distribution

ADVERTISE   |   MAGAZINE SUBSCRIPTIONS   |   FREE BREAKING-NEWSLETTERS!   |   SYS-CON.TV   |   BLOG-N-PLAY!   |   WEBCAST   |   EDUCATION   |   RESEARCH

.NET Developer's Journal - .NETDJ   |   ColdFusion Developer's Journal - CFDJ   |   Eclipse Developer's Journal - EDJ   |   Enterprise Open Source Magazine - EOS
Open Web Developer's Journal - OPENWEB   |   iPhone Developer's Journal - iPHONE   |   Virtualization - Virtualization   |   Java Developer's Journal - JDJ   |   Linux.SYS-CON.com
PowerBuilder Developer's Journal - PBDJ   |   SEO / SEM Journal - SJ   |   SOAWorld Magazine - SOAWM   |   IT Solutions Guide - ITSG   |   Symbian Developer's Journal - SDJ
WebLogic Developer's Journal - WLDJ   |   WebSphere Journal - WJ   |   Wireless Business & Technology - WBT   |   XML-Journal - XMLJ   |   Internet Video - iTV
Flex Developer's Journal - Flex   |   AJAXWorld Magazine - AWM   |   Silverlight Developer's Journal - SLDJ   |   PHP.SYS-CON.com   |   Web 2.0 Journal - WEB2
Apache   |   CMS   |   CRM   |   HP   |   Oracle Journal   |   Perl   |   Python   |   Red Hat   |   Ruby on Rails   |   SAP   |   SaaS

SYS-CON MEDIA:   ABOUT US   |   CONTACT US   |   COMPANY NEWS   |   CAREERS   |   SITE MAP
SYS-CON EVENTS:   |  AJAXWorld Conference & Expo  |  iPhone Developer Summit  |  Cloud Computing Conference & Expo  |  SOA World Conference & Expo  |  Virtualization Conference & Expo
INTERNATIONAL SITES:   India  |  U.K.  |  Canada  |  Germany  |  France  |  Australia  |  Italy  |  Spain  |  Netherlands  |  Brazil  |  Belgium
 Terms of Use & Our Privacy Statement     About Newsfeeds / Video Feeds
Copyright ©1994-2008 SYS-CON Publications, Inc. All Rights Reserved. All marks are trademarks of SYS-CON Media.
Reproduction in whole or in part in any form or medium without express written permission of SYS-CON Publications, Inc. is prohibited.
 
close this window