Monday, December 1, 2003

Using a reusable code approach to HTML select option lists, part V

It's in this latter entry that you identify the class name of the OptionListSourceFactory and the name of the specific OptionListSource that applies to the field to which this entry is related. You define the validator once in the validator-rules.xml file, and then reference it as many times as you need for individual field validation in the validation.xml file.

Client-side validation

The Struts 1.1 validation framework provides the capability for both server-side and client-side field validation. I took the easy route and just implemented the server-side validation without taking the next logical step and adding the appropriate Javascript to the validator-rules.xml file entry to handle the client-side component. Obviously, there's a way to utilize our framework to get the valid values to the Javascript so that client-side validation can be added to the mix, but I'll leave that to you to explore on your own.

My intent here was just to demonstrate that once you create a component for one purpose, you often find that there are other, equally valuable uses for your component, and I believe that we have accomplished that with the server-side validation alone.

Now what?

Hopefully, I have accomplished my goal of demonstrating some practical applications of the concepts that I have been promoting, and as a side benefit, produced something of value to someone at the same time. That's about it for the code examples, but next time I do want to wrap things up by going back to the original concepts and doing a little review.

Jeff Chilton is Vice President of Fulfillment at Echo Technology Group, Inc., an IT consulting firm that specializes in enterprise-focused best practices. He can be reached at jchilton@teametg.com.