-----Original Message-----
From: A. C. [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 01, 2001 1:59 PM
To: [EMAIL PROTECTED]
Subject: Re: refresh of Session scoped beans


> A recent thread out here has me playing with the "scope" attribute of the
> <jsp:useBean> tag. Unfortunately, I have hit a wall. When using a bean of
> scope="session", which is populated from an HTML form using a
> <jsp:setProperty name="foo" property="*"/>. The initial population of the
> bean is OK, however when I hit "back" on the browser to make corrections
to
> the form data, subsequent updates of the beans information are not
> successful. This is alleviated by using a bean of scope="request", however
> that is not what I need. Anyone encounter this problem and have a
> solution???

I solved the problem "resetting" the bean.
Instead of the useBean tag, i use:
myBeanClass bean = new myBeanClass();
session.setAttribute("id bean istance", bean)
So each time u acces to this page, the bean is resetted to the deafult
value.
After this, u'll have to put the setProperty * tag to initialize the bean
with the new values submitted.
P.S.: Remember that using the setProperty * feature, the corresponding set
methods are called only if the corresponding form field is not empty. I
mean, if u fill & submit the form, then u come back, delete a field and then
submit again, the field u deleted won't be set to a null value in the bean
but it will keep the old value. It's better to use manually the set property
methods: bean.setProperty1("value") for each fields of the form.
====================================================================
Thanks for the reply.

I agree that this will solve the problem, but at the same time doesn't that
defeat alot of the "convenience" associated with the JSP/Beans combo? For a
large form, that is alot of bean.setProperty... calls.

I wonder if there is a better way?

Thanks for the heads up on the blank form fields are not set to null thing.
I'm sure that would have bothered me in the future.

-Pete

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to