This is exhaustively dealt with at http://virtualschool.edu/wap.
In particular see the sections titled "Beans are not mode of strings"
(or any generic java type). Beans should be made of application-specic
field types that encapsulate their own custom validation rules. This
is a third and better alternative to those consider below.
On Tuesday, June 26, 2001, at 11:41 AM, Quinn Stone wrote:
> 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
>
---
For industrial age goods there were checks and credit cards.
For everything else there is http://virtualschool.edu/mybank
Brad Cox [EMAIL PROTECTED] 703 361 4751
___________________________________________________________________________
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