Side-stepping the question a bit, my preference is to have very tolerant
setters on all my beans/business objects.
Basically, just about whatever format the data comes in, the setters try to
take it.
A typical example, if you have a native instance variable of type Date;
provide setters for Strings, longs and Date; and for the Strings - check for
the different possible formats the user of your bean may attempt to use. I
like code that is forgiving, and keeps on ticking.
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet API
Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Quinn Stone
Sent: Tuesday, June 26, 2001 11:42 AM
To: [EMAIL PROTECTED]
Subject: Bean Validation
Hello:
I am trying to decide the best way to implement data validation in my
beans:
1. Add a boolean validate() method that checks the bean's properties,
populating a message Vector that can be retrieved later.
2. Throw a custom ValidationException in the setters.
Number 1 is clean, but lets bad data into the bean, and requires the
developer to know the sequence of calls.
Number 2 puts a hard shell on the bean, but is a little cumbersome
because of the try/catch around calls to the setters.
Opinions?
--
Quinn Stone
Stone Consultants
2214 1/2 Santa Clara Ave.
Alameda, CA 94501
510.865.7342
www.stoneconsultants.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html