The infrastructure at http://virtualschool.edu/wap works exactly the way
you want. The only exception is that you need to adjust that notion that
beans are made of Strings. Beans should be made of application-specific
Fields that validate input internally, not application-independent
datatypes like Strings, floats, or ints, for which validation must be
recoded every time you create a bean.
Try it. You'll like it.
On Saturday, June 23, 2001, at 10:56 AM, Quinn Stone wrote:
> The problem is that I want the errors to be displayed on the same page
> the user changed the data rather than a separate error page. The page
> where the user changed the data reads from the data bean, which has data
> types other than String.
>
> I'm starting to think that the only way to do it is have redundant
> String properties for each bean property that is not a String, so I can
> display the user's input back to them even if they make a data type
> error in their input.
>
> q
>
> Michael Weller wrote:
>>
>> why don't you simply validate the user's input before you create the bean
>> with the validated values. if an error accurs while validation make your
>> event handler return an error bean with some information about the error,
>> let your controller check whether this is an error bean or another one, if
>> it's an error bean call ur error.jsp.
>>
>> Hope this helps.
>>
>> -mw
>>
>> ----- Original Message -----
>> From: "Quinn Stone" <[EMAIL PROTECTED]>
>> To: <[EMAIL PROTECTED]>
>> Sent: Saturday, June 23, 2001 12:34 AM
>> Subject: Need guidance on form validation.
>>
>>> 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
>>>
>>
>> ___________________________________________________________________________
>> 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
>
> --
> 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