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]

Reply via email to