See http://virtualschool.edu/wap. Pay particular attention to the section
under "The Problem" titled "Beans are not made of Strings" (nor any generic
Java type, e.g. double). Beans are made of application-specific Field types
that know how to validate themselves, not generic Java types.

On Friday, June 22, 2001, at 06:34 PM, Quinn Stone wrote:

> Hi:
>
> I hope someone has come up with an elegant method that solves my
> problem, and is willing to share.
>
> My application is based on the Chapter 6 sample in Wrox "Professional
> JSP 2nd Ed."):
>
> 1. Controller looks up and calls an event handler's process() method.
> 2. The event handler populates one or more beans using JDBC/mySQL and
> stuffs them in session/request as required.
> 3. Controller forwards to jsp, which uses beans to display stuff in a
> form.
>
> Fine so far. Now, the user can update the form fields and click an
> "Update" button, which starts the above steps going again.
>
> If the event handler now finds an error in the user's input, it creates
> an error bean and the controller forwards to the jsp again. I want the
> jsp to display the erroneous input as well as the error messages.
> However, the bean that the jsp is reading from has data types that may
> not accept the user's input. For example, the user might put 15.q0
> (after all, the 'q' is really close to the 'one' key) in a form field
> that is defined as a double in the bean.
>
> I thought, OK, just make the bean properties Strings, and I won't have
> to worry about it. The problem with this is that then I will have to do
> data type conversions whenever I want to use the bean to actually do
> some processing (for example, add the double value to something, do some
> date manipulation, etc.), which makes things, well, ugly.
>
> I suppose I could keep one bean with nothing but String properties
> (string bean?) for display, and another with correct data types, but
> that's ugly, too, unless there's a nice way to accomplish this that I
> haven't thought of.
>
> I really don't want to have two jsp's displaying the same info, or add
> conditions to the jsp causing it to read from the bean or the request
> depending on the situation.
>
> Now that you've waded through all that, any suggestions?
> --
> 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

Reply via email to