Search DominoPower's 11,323 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
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Five trends for 2010
DominoPower TV Episode 1: Inside a strategy session with Teamstudio
More about Domino log files
Say goodbye to the Uh-Ohs. Long live the Tens.
Why your log.nsf might not be purging properly
Latest Lotus Headlines
Recommended Maintenance - Lotus Notes Traveler
Here are the slides and other materials from our Lotusphere session
Microsoft OCS awareness in Lotus Connections and Websphere Portal?
SnTT: XPages Blank Calendar Control (Part 2), adding data
Have your Lotus Notes calendar display multiple time zones
Sample Database for Microsoft Office and Lotus Symphony Integration
Symphony 3.0 beta signals another attack on Office
>> Read all the news
More from the ZATZ journals
Computing Unplugged: The iPad: Apple's latest heartbreaker
David Gewirtz Online: CNN commentary and analysis
OutlookPower: Running auto-respond rules when Outlook is closed
-- Advertisement --

Power Tools 6.0 is a set of 90 administrative utilities for Lotus Notes & Domino
Power Tools simplifies management of the Notes/Domino environment by automating routine tasks. Power Tools can manage or monitor mail files, groups, ACLs, agents, LOG.NSF, templates and more.

Download a trial version from helpsoft.com.
-- Advertisement --

Teamstudio announces the 2010 spotlight awards winners!
We had some extraordinary submissions for the 3rd annual Teamstudio Spotlight Awards, and choosing the winners was no easy task for our judges! Click here to find out who won, and to learn more about these remarkable applications and the genius developers behind them!

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