Search DominoPower's 11,420 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.
Using a reusable code approach to HTML select option lists (continued)

Our abstract class implements the getOptions() method by checking to see if the options have been loaded before returning the options. If the options have not been loaded, it performs a new method to load the options before returning them to the calling module. Since there are a variety of sources from which we can obtain our options, we'll leave the actual loading of the options to the implementing classes by defining an abstract method that implementing classes will need to implement.

Create an implementation-specific final class
Now that we have our interface and an abstract class that implements the interface, we can create one or more implementing classes to complete our mini framework. We could obtain our list of options from a JDBC database, an LDAP directory, a Java Properties object, an XML file, a text file containing name/value pairs, or any other number of sources. However, in keeping with our "let's keep things simple to start with" approach, let's begin with just a simple String containing a comma-separated list of values, and to make things even simpler, for this first exercise let's assume that the same value will be used for both the label and the value fields of our LabelValueBeans.

Listing 3 contains our SimpleOptionListSource class, which extends the OptionListSourceBase class and implements the loadOptions() method. This class also includes a constructor that accepts a String as a parameter so that we can pass our comma-separated values to the object at creation time.


package step.one;

import java.util.ArrayList;

import org.apache.struts.util.LabelValueBean;

/**
* Returns the name/value pairs for the options related to an HTML
* "select" tag.
*
* Source data for this implementation is obtained directly from the
* option list string provided.
*/
public class SimpleOptionListSource extends OptionListSourceBase {
private String optionList = null;

/**
* Constructs a new "SimpleOptionListSource" object using the parameters
* provided.
*
* @param optionList a String containing the comma separated values for
* the option list
*/
public SimpleOptionListSource(String optionList) {
this.optionList = optionList;
}

/**
* Loads the list of available options from the optionList
* String passed to the constructor.
*/
protected void loadOptions() {
ArrayList list = new ArrayList();

String remaining = optionList;
while (remaining.indexOf(",") > -1) {
int index = remaining.indexOf(",");
String thisItem = remaining.substring(0, index);
if (index < remaining.length()) {
remaining = remaining.substring(index + 1);
} else {
remaining = "";
}
LabelValueBean thisOption = new LabelValueBean(thisItem, thisItem);
list.add(thisOption);
}
if (remaining != null && !remaining.equals("")) {
LabelValueBean thisOption = new LabelValueBean(remaining, remaining);
list.add(thisOption);
}

setOptions(list);
}
}


« Previous  ·  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
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
Five trends for 2010
Latest Lotus Headlines
New Notes/Domino Technotes published about Chile's extended daylight saving time
SnnT: How to prevent Google from listing your Sametime Server
How to send someone an email that shows your calendar availability
"The collection has become invalid"
More XPages onclick event weirdness...
Domino 8.5.1 Fix Pack 1 Interim Fix 1 (8.5.1 FP1 IF1) - DAOS Fixes
Domino Designer 8.5 Tip: Where Working Sets Are Stored
>> Read all the news
More from the ZATZ journals
Computing Unplugged: Make Mafia Wars an offer it can't refuse
David Gewirtz Online: CNN commentary and analysis
OutlookPower: Removing an Office installation that doesn't want to go away
-- Advertisement --

Find unused Lotus Notes groups and clean up your address book
Have you ever wanted to get rid of old Lotus Notes groups that were cluttering up your address book, but you weren't sure if they were used? Find Unused Groups can help.

Find Unused Groups will check your mail and ACL groups to help you determine if they are used, and who uses them.

Learn how to easily clean up your address book.

-- Advertisement --

Integrate your Notes Applications with Microsoft Office and Symphony
Integra for Notes Integrates Microsoft Office and/or IBM Lotus Symphony
Requires NO change to the design of the appliation or Installations of DLL's and EXE's
  • Integra is a ready to use solution, enhance static reports with Excel data analysis, pivot tables, macros
  • User friendly aproach, using a point and click access to features
  • Reports from any Lotus Notes databases
  • Runs reports through a Notes client, web browser and scheduled basis
  • Allows use of LotusScript for advanced data manipulation
  • Enables self service reporting capabilities to end-users


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