Search WebSpherePower's 6,567 WebSphere, Java, and Eclipse 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, part IV
By Jeff Chilton

"Success depends upon previous preparation, and without such preparation there is sure to be failure."
-- Confucius (ancient Chinese philosopher, 551BC-479BC)

If you have been following this series, you're now intimately familiar with our little framework for populating HTML select statements with options from a variety of potential sources. If you have not, you might want to go back and take a look at Parts I, II, and III before you go too far, just to get a little background on what we have accomplished so far.

Certainly, the framework as we left it last time could be considered complete as is; however, there is one little flaw that I don't care for as it stands, and I would like to correct that. Our components are, in fact, reusable and externally configurable, and are even interchangeable to a large degree. The problem that I have with things the way they stand is that the using applications are the ones that have to do the configuring. I like to build reusable applications that are pretty ignorant of their implementation-specific differences, which means that I don't like to see the application module passing configuration parameters to the components they're using. My preference is for the application modules to receive their components pre-configured through some process that delivers the components already set up and ready to go. I've found that the simplest way to do that is to create a component factory.

Component factory concepts
A component factory is just what the name implies: something that produces components. The basic component for our little framework is the OptionListSource. Physically, the OptionListSource is a Java Interface, but you can refer to Java objects by the name of any Interface that the object implements, and this is the most generic way to reference a collection of similar-but-different components that all serve the same purpose.

Generally speaking, the application modules will assume the role of consumer in the factory/consumer relationship. The consumer orders its components from the factory, and the factory fills orders by instantiating and configuring objects based on the configuration parameters in effect for the application. The factory deals with the configuration issues, selects the specific implementation to instantiate, and passes all of the appropriate parameters to the component before returning it to the consumer. From the perspective of the consumer, there is no specific knowledge of whether their OptionListSource object is a SimpleObjectListSource, a PropertiesOptionListSource, an SqlOptionListSource, or some other yet-to-be-conceived implementation. Not only does the consumer not know, it doesn't need to know, and really shouldn't care, since all implementers of the OptionListSource interface support the exact same behavior.


1  ·  2  ·  3  ·  Next »
Other articles you might like
Home > Projects > Reusable Code (5 articles)
   Using a reusable code approach to HTML select option lists, part VI
   Using a reusable code approach to HTML select option lists, part V
   Using a reusable code approach to HTML select option lists: part III
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent WebSpherePower Articles
A perfect 10: celebrating 10 years online
You can help bring security and safety back to White House email
Introducing the WebSpherePower RSS feeds
From New Jersey to Palm Bay, Florida
A WebSphere pot o' gold
How Elvis entered the building and CES went out the window
WebSphere Application Server 6: what's it all mean?
WebSpherePower News
Submit your Abstracts Today for 2010 Exceptional Web Experience
Building Web Reputation Systems
Accusations Fly in Viacom, YouTube Copyright Fight
Cybercrime's bulletproof hosting exposed
O'Reilly Velocity Conference Opens Registration and Reveals Program
SAN SnapShot Backup for VMWare
What users want from Oracle's Java Community Process
>> Read all the news
More from the ZATZ journals
Computing Unplugged: Online safety for virtual learning
David Gewirtz Online: CNN commentary and analysis
DominoPower: Syncing Notes with Android phones
OutlookPower: Seek and find: Strategies to locate filed-away emails fast
-- Advertisement --

Coming soon, new book: How To Save Jobs
This book is about how to create and save jobs. Believe it or not, there's not a single book out there that specifically focuses on job creation and preservation -- until now.

This book, by ZATZ editor-in-chief David Gewirtz, is about helping your business work better. It's about helping you change the things you need to change so your company can perform more effectively.

Plus, through a grant from ZATZ, it's a free download.

Read it and reap.

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