Hello, Even if Struts is passing a true reference to the form bean that is stored in the session, doing that reassignment inside the dispatch method won't do what you want. ************* public ActionForward setUpForNew(ActionMapping mapping, ActionForm form, ...{ form = new MyForm(); ************* That reassignment is just reassigning the local pointer to the new form instance, disconnecting it from the form instance in the session. To do what you want i think you would need to:
MyForm newForm = new MyForm(); session.setAttribute("nameOfMyFormInActionTag"); Right? that would replace the instance in the session with the new instance you just created. Dave On Fri, 2006-04-21 at 19:07 -0400, Rick Reumann wrote: > I haven't used Session scope for my ActionForms in a lonnnngggg time, > but now I need to for a particular scenario. > > The problem I'm running into is imagine you click on a link to "Create > New" - in which case, after you pass through your Action, you'd go to > a page backed by the session-scoped ActionForm. If the ActionForm has > stuff already in it, form say an edit process done earlier, this will > show up on your form which isn't what you want in a "create new" > sencario. To avoid this on the "new" situations I thought I could just > hava a setUpForNew(..) dispatch method and do something like... > > public ActionForward setUpForNew(ActionMapping mapping, ActionForm form, ...{ > form = new MyForm(); > //maybe set a few things before I leave > //return > } > > Then I mistakingly thought when I return to my JSP, the backing > ActionForm would be pointing to this new ActionForm instance and all > my properties would be set to their defaults. > > However, that above apparently is not working and I think I remember > way back running into this and I think I remember the problem maybe > being related to that the form bean referenced in my action method > isn't really a true reference to the one that is actually in Session > scope .. I think Struts does some funky stuff behind the scenes.. > can't remember all the details. > > So for those of you that use Session scope a lot, what is the easiest > way to get a 'blank reset' form? Obviously I could go and reset every > single property in the reset method and call that from my Action, but > that seems like a lot of work and could get sloppy and introduce > errors (later on you forget to reset a prop there etc). > > Am I totally missing something simple to accomplish what I want? > > Thanks, > > -- > Rick > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]