struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Reumann" <ric...@gmail.com>
Subject Session lovers... how do you handle this 'common?' situation?
Date Fri, 21 Apr 2006 23:07:05 GMT
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message