Doh! I forgot that part. Yup, that's really the way to go, but only *if* your action has the form you want mapped to it. Sometimes a separate action with no input form is used to instantiate and/or initialize a form, and in that case, mapping.getAttribute() won't get you the form name you need.
Hubert --- Paul McCulloch <[EMAIL PROTECTED]> wrote: > Rather than hard coding the attribute name you can get that from the > mapping: > > request.getSession().setAttribute(mapping.getAttribute(), form); > > Paul > > > -----Original Message----- > > From: Hubert Rabago [mailto:[EMAIL PROTECTED] > > Sent: Monday, April 19, 2004 4:20 PM > > To: Struts Users Mailing List > > Subject: Re: session scoped action form question > > > > > > Try overwriting the form in the session with your new form: > > > > form = new WidgetForm(); > > request.getSession().setAttribute("formName", form); > > > > > > --- "Barnett, Brian W." <[EMAIL PROTECTED]> wrote: > > > Can someone enlighten me as to why when I instantiate a new > > ActionForm, the > > > old data seems to hang around? Here is the information: > > > > > > > > > > > > I have a session scoped action form defined in struts config: > > > > > > > > > > > > <action name="WidgetForm" path="/widget" scope="session" > > > > > > type="com.mystuff.WidgetAction" validate="false"> > > > > > > <forward name="Add" path="AddWidget.pg"/> > > > > > > etc, etc, > > > > > > </action> > > > > > > > > > > > > My dispatch method looks something like this: > > > > > > > > > > > > public ActionForward addNewWidget(ActionMapping mapping, > > > > > > ActionForm form, > > > > > > > > HttpServletRequest request, > > > > > > > > > HttpServletResponse > > > response) { > > > > > > form = new WidgetForm(); > > > > > > ((WidgetForm) form).setMode(Constants.MODE_INSERT); > > > > > > return mapping.findForward(Constants.ADD); > > > > > > } > > > > > > > > > > > > Assume that prior to adding a new widget, the user has > > already edited an > > > existing one, so the session-scoped WidgetForm is populated > > with the edited > > > widget's info. > > > > > > > > > > > > After the addNewWidget() method is called and the user is > > sent to the add > > > page, the previous edited widget's data still displays. Why is this? > > > Doesn't > > > the line "form = new WidgetForm();" wipe out the old object? > > > > > > > > > > > > Essentially, I just want an empty WidgetForm when the user > > wants to add a > > > new widget. I was hoping not to have to write a "clear" > > method for all of > > > my > > > session scoped ActionForms. I'm sure there's a simple > > solution, please > > > enlighten me. > > > > > > > > > > > > (I hope the syntax is correct above. I was typing from > > memory. I don't have > > > the code here in front of me.) > > > > > > > > > > > > Thanks, > > > > > > Brian Barnett > > > > > > > > > > > > > > > > > > __________________________________ > > Do you Yahoo!? > > Yahoo! Photos: High-quality 4x6 digital prints for 25¢ > > http://photos.yahoo.com/ph/print_splash > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > ********************************************************************** > Axios Email Confidentiality Footer > Privileged/Confidential Information may be contained in this message. If > you are not the addressee indicated in this message (or responsible for > delivery of the message to such person), you may not copy or deliver this > message to anyone. In such case, you should destroy this message, and > notify us immediately. If you or your employer does not consent to Internet > email messages of this kind, please advise us immediately. Opinions, > conclusions and other information expressed in this message are not given > or endorsed by my Company or employer unless otherwise indicated by an > authorised representative independent of this message. > WARNING: > While Axios Systems Ltd takes steps to prevent computer viruses from being > transmitted via electronic mail attachments we cannot guarantee that > attachments do not contain computer virus code. You are therefore strongly > advised to undertake anti virus checks prior to accessing the attachment to > this electronic mail. Axios Systems Ltd grants no warranties regarding > performance use or quality of any attachment and undertakes no liability > for loss or damage howsoever caused. > ********************************************************************** > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > __________________________________ Do you Yahoo!? Yahoo! Photos: High-quality 4x6 digital prints for 25¢ http://photos.yahoo.com/ph/print_splash --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]