ITworld.com
  Search  
ITworld Home Page ITworld Webcasts ITworld White Papers ITworld Newsletters ITworld News ITworld Topics Careers ITworld Voices ITwhirled Changing the way you view IT
Personalize Your Web site with Skins, Part 1
ASP TUTOR --- 07/16/2001

Brian R.J. Heumann

Your Web site's appearance says loads about your organization's core values. However, it's almost impossible to find a visual design that pleases everybody -- and rolling out a professional design and keeping it consistent throughout the Web site is hard work. You cannot make major changes to the visual design without disrupting other elements, such as the layout or the HTML code. 

On this topic

However, you can provide your users with a way to customize your Web site to their individual tastes without obstructing the underlying code. With skins, you can create different professional visual designs for your site and give your users a choice of which look and feel they would like to see. And you can do it all without disrupting your JavaServer Pages (JSP) or HTML code!

This article will show how you can use a skin server to add some personalization to your Web site. You can use the JSPs in Resources as a starting point for integrating user preferences in your enrollment procedures or your customer self-management features, for example.

Factor out visual elements
A Web site's design can be broken into a set of key visual elements that are independent of the underlying HTML or JSP code. A file represents each visual element. For example, GIF or JPEG files symbolize logos or icons; other styles or preferences can be stored in cascading style sheets (CSS) and represented by CSS files. Make sure that you identify and factor out generic visual elements that are loosely coupled with the inner logic, content, or tone of your Web site. A skin consists of a set of these visual elements, or files, and can be easily exchanged without disrupting your HTML or JSP code. Exchanging a skin simply means exchanging the relevant files.

With only a few changes to your Web site's code, you can request visual elements for a particular skin from a skin server instead of referring to specific underlying files. For example, if you factored out the logo element for your site, the skin server could provide a version of the logo that would change depending on the user's preferences. Internally, the skin server maps the request to a file. For example, if a user who has chosen the Blue Ocean skin wants to download the site logo, the request is mapped to the file data/blue_ocean_logo.gif. In this way, you can easily add new skins without changing your JSP or HTML code.

Add user preferences
Every customizable Web site needs to process and store individual user preferences. A user's collection of preferences is often called a user profile. A user profile might store the visual design the user prefers - - the Blue Ocean design, for example. The sample code in this article uses a JavaBean to store and process a user profile.

Listing 1 contains the code for a form where users enter their preferences for a user ID and a skin. I designed this simple form to highlight the use of personalization; in a real-world Web site, the user profile could hold more information about the user's preferences.

Listing 1: ChangeUserProfile.jsp

<.%@ page contentType="text/html" language="Java" import="UserProfileBean" %> <.jsp:useBean id="userProfile" class="UserProfileBean" scope="session" /> <.jsp:setProperty name="userProfile" property="*" /> <.%! private String isSkinChecked( UserProfileBean userProfile, String skin ) { String checkmark = (userProfile.getPreferredSkin().equals (skin))? "CHECKED":"" ; return checkmark; } %>

<.head>
<.title>Enter your profile<./title> <.meta http-equiv="Content-Type" content="text/html; charset=iso- 8859-1"> <./head>

<.H1>Enter your profile:<./H1>
<.BR> <.form method="post" action="http://localhost:8080/skins/jsp/ProcessUserProfile.jsp">

<.TABLE>
<.TR valign="middle"> <.TD>User ID: <./TD> <.TD><.INPUT TYPE='text' NAME='userId' value='<.jsp:getProperty name="userProfile" property="userId" />'><./TD> <./TR>

<.TR>
<.TD colspan="2"> <./TD> <./TR>

<.TR valign="top">
<.TD>Skin: <./TD> <.TD> <.INPUT TYPE="radio" NAME="preferredSkin" VALUE="green_piece" <.%= isSkinChecked (userProfile, "Green Piece") %>> Green Peace <.BR> <.INPUT TYPE="radio" NAME="preferredSkin" VALUE="blue_ocean" <.%= isSkinChecked(userProfile, "Blue Ocean") %>> Blue Ocean<.BR> <.INPUT TYPE="radio" NAME="preferredSkin" VALUE="red_whip" <.%= isSkinChecked(userProfile, "Red Whip") %>> Red Whip<.BR> <./TD> <./TR> <./TABLE>

<.DIV ALIGN="center">
<.input type="submit" name="Submit" value="Submit"> <.input type="reset" name="Submit2" value="Reset"> <./DIV>

<./form>

ChangeUserProfile.jsp contains a set of radio buttons with which the user can select a skin. The radio buttons' names map to the property preferredSkin of the userProfile bean. When the user submits the form, the bean's property is set to the value of the selected radio button. For example, if the user selected the Blue Ocean radio button, the bean's property preferredSkin would then hold the value blue_ocean.

Next Week: Personalize Your Web site with Skins, Part 2

 

Brian R.J. Heumann is a user-centered design consultant at IBM. He has several years of experience working with object-oriented technologies and software development, especially Java, HTML, and JSPs. He develops Websites for e-commerce, presentations, and portals.



Advertisements
Sponsored links
Top 5 Reasons to Combine App Performance and Security
KODAK i1400 Series Scanners stand up to the challenge
Locate Hidden Software on business PCs with this free tool
Bring harmony to your mix of UNIX-Linux-Windows computing environments
 Home   Newsletters  ASP TUTOR
www.itworld.com    open.itworld.com     security.itworld.com     smallbusiness.itworld.com
storage.itworld.com     utilitycomputing.itworld.com     wireless.itworld.com

 
Contact Us   About Us   Privacy Policy    Terms of Service   Reprints  

CIO   Computerworld   CSO   GamePro   Games.net   Industry Standard   Infoworld   ITworld  
JavaWorld   LinuxWorld  MacUser   Macworld   Network World   PC World   Playlist  

DEMO   IDG Connect   IDG Knowledge Hub   IDG TechNetwork   IDG World Expo  

Copyright © Computerworld, Inc. All rights reserved

Reproduction in whole or in part in any form or medium without express written permission of Computerworld Inc. is prohibited. Computerworld and Computerworld.com and the respective logos are trademarks of International Data Group Inc.