Daniel R�nnqvist wrote:

> Hello.
>
> I want my form to retrieve the values last entered if I press back in my
> browser after the from has been posted. Is there an easy way to do this
> without putting the fields in a session object and then get them from that
> object ?

This is exactly the approach I use.  I build a bean that has properties for all
the fields on my form (or pages if it's a multi-page input), and store it in the
session.  When the form is submitted, these values are validated -- if OK, I go on
and process them, otherwise I return to the input form with an error message and
the form pre-filled-out with the user's last inputs.

In this bean, I also do a couple of other things to make life easier on the JSP
page developer:

* Initialize property values to the appropriate defaults
  when the bean is first created.  That way, the first
  time a user navigates to the page (where there was
  no previous session bean stored), the <jsp:useBean>
  action will create it for me.

* Convert all null String values into "" (zero-length String)
  instead, so I don't have to special-case all of the property
  lookups.


> Maybe a built in function as I would believe that this is a common
> request.
>

It seems pretty difficult to articulate a general solution when you don't know
what field names are of interest, what underlying data types are being used, and
what underlying logic is used to translate input values into property values.

>
>  have a nice day.
>  Daniel Ronnqvist, ABCD Stockholm
>

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to