Search DominoPower's 11,441 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
PROGRAMMING POWER
Using a reusable code approach to HTML select option lists
By Jeff Chilton

"Our life is frittered away by detail... Simplify, simplify."
-- Henry David Thoreau (1817-1862)

I usually ramble on about application development philosophies without ever getting down to any real, concrete applications of the theories, so I decided that it was time to actually do something meaningful to demonstrate in a practical way what it is that I'm always talking about. I also decided to tackle something simple, just to keep the focus on the concepts rather than the specific application.

If you've ever done any work with Struts custom tag libraries, you've invariably come across the html:select tag, and the accompanying html:options tag. Used together, these tags render a nice HTML select statement, which gives you the familiar drop-down list of choices from which to choose your input value. It's this list of choices that will be the focus of our explorations here. There are a number of ways to feed the values of these choices to the Struts tags, but for the purpose of this discussion, we're going to focus on the method that uses a collection, which is simply a Java ArrayList of labels and values. Struts even provide a nice bean object for such an array, called interestingly enough, a LabelValueBean. The Struts LabelValueBean has two fields, a label and a value, and the accompanying getters and setters for both fields.

All you need to do in order to take advantage of these components is to load your ArrayList with the appropriate LabelValueBeans and point your html:options tag to this collection. There is more than enough material in existence on just exactly how to do this, so I won't bother to repeat any of that here. What we're going to focus on is a way to consistently produce these collections of LabelValueBeans from a variety of sources.

Create an Interface
Whenever I want to create a plug-compatible framework for anything, I start with the Java Interface. The Interface defines the rules for the behavior of the modules that you want to plug and unplug into your system, and generally speaking, I always identify replaceable components by the Interface name as opposed to the actual name of the object. This is just a good practice to get into, so that you're referencing the contract and not a specific implementation of the contract. We will begin with a simple one-method interface, and then later we can expand it to add additional features. Our interface is presented in Listing 1:


1  ·  2  ·  3  ·  4  ·  Next »
Other articles you might like
Home > Internet Technologies > HTML and CSS (15 articles)
   One reader's opinion on HTML mailing
   Keep lookin' good with Cascading Style Sheets
   Cascading Style Sheets make you look good
Home > Internet Technologies > Java (6 articles)
   FlowBuilder 3.0: Domino's bridge into J2EE
   Post-Lotusphere 2004 report: gaining understanding and perspective
   Survey reveals trends in Java use on Domino
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Application development, William Shatner, and the origin of the universe
Learn Domino Designer 8.5 for free
The (near) future of Sametime, Quickr, Connections, and Symphony
Inside the IBM Innovations lab
Lotusphere 2010: Hot fixes and cool news for Notes, Domino, and LotusLive
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Latest Lotus Headlines
Xpages not loading? JVM errors? - Solution
How to implement an iCalendar feed into your Notes calendar with XPages
DWA Hotfixes for Domino 8.5.1FP1 - A Gotcha
IBM Adds DB2 to Lotus Foundations SMB Package
SNTT : XPages onclick Ghosts in the machine
Ports used by Lotus Sametime 8.5 servers
Exploring a Domino Date Bug
>> Read all the news
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
OutlookPower: More about disappearing text
-- Advertisement --

Learn Notes and Domino 8 at your place and pace!
Learn Notes and Domino in your office and/or home! TLCC's highly acclaimed distance learning courses for users, developers, and admins will enhance your career and your resume.

The many included activities and demos will make you a pro! Expert instructor help is a click away.

Click here to try a FREE demo course!!

-- Advertisement --

Teamstudio Edition 25 has shipped
It's finally here! Now that Teamstudio Edition 25 has shipped, listen to our latest Tool Time audio program to find out what's changed. Updates to all your favorite Teamstudio tools will be discussed.

Plus, you'll get an introduction to Teamstudio Undo (formerly known as Teamstudio Snapper).

Tap here to get started!

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login