Re: Passing ActionForm along on the request

2004-05-27 Thread DGraham

I ran into a similar situation where
my session scoped bean was being reset between chained actions. The
solution put forth by Ted Husted in his book Struts in Action,
is to add a boolan property to the form, called mutable
including setMutable()
. This property would be checked by the various mutators to determine
if the properties can/should be modified.

In your scenario, after actions.MyActionSubmit
executes, it would call setMutable(false)so
that the form won't actually reset before being dispatched to actions.MyNextAction.

Dennis






Jeremy Nix
[EMAIL PROTECTED] 
05/26/2004 10:35 AM



Please respond to
Struts Users Mailing List [EMAIL PROTECTED]





To
[EMAIL PROTECTED]


cc



Subject
Passing ActionForm along
on the request








Is it possible to call an Action which pre-populates
a form, forwards on
to a JSP page which displays the form values for the user to change, and
then submit back to an Action that will contain the form value? We're
running into a scenario where we prepopulate the Form in 1 action and
set it onto the Request. The jsp displays some of the values so that
they may be modified, and then submits back to a second action where the
Form is to be populated. When the form is submitted to the 2nd Action,
the ActionForm is reinitialized, and ends up throwing an exception in
the BeanUtils.populate method because an object on the form is null.
We've found that the scenario works fine when using Sessions, but runs
into issues when using the request. 

Here's a sample struts config:

action

path=/actions/MyAction

type=actions.MyAction

name=myActionForm

scope=request

validate=false

forward
name=continue path=/actions/MyAction.jsp/
/action   
   
   
  


action

path=/actions/MyActionSubmit

type=actions.MyActionSubmit

name=myActionForm

scope=request

input=/actions/MyAction.jsp
  validate=true

forward
name=continue path=/actions/MyNextAction/
/action

We already have 1 solution (using sessions), but given the fact that
we're going to be working in a load-balanced environment with multiple
Tomcat instances, we are trying to use the session sparingly.

Another solution that I just thought of would be to replicate all the
values of the Form as hidden values on the JSP page so that they would
be repopulated on the submit. This would be slightly annoying, but
is a
viable solution.

My question is, is there another solution that works as clean as
sessions but uses the request?


_
Jeremy Nix
Senior Application Developer
Southwest Financial Services, LTD.
(513) 621-6699 x1158
www.sfsltd.com



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Passing ActionForm along on the request

2004-05-26 Thread Jeremy Nix
Is it possible to call an Action which pre-populates a form, forwards on
to a JSP page which displays the form values for the user to change, and
then submit back to an Action that will contain the form value?  We're
running into a scenario where we prepopulate the Form in 1 action and
set it onto the Request.  The jsp displays some of the values so that
they may be modified, and then submits back to a second action where the
Form is to be populated.  When the form is submitted to the 2nd Action,
the ActionForm is reinitialized, and ends up throwing an exception in
the BeanUtils.populate method because an object on the form is null.
We've found that the scenario works fine when using Sessions, but runs
into issues when using the request.  

Here's a sample struts config:

action
path=/actions/MyAction
type=actions.MyAction
name=myActionForm
scope=request
validate=false
forward name=continue path=/actions/MyAction.jsp/
/action   

action
path=/actions/MyActionSubmit
type=actions.MyActionSubmit
name=myActionForm
scope=request
input=/actions/MyAction.jsp
validate=true
forward name=continue path=/actions/MyNextAction/
/action

We already have 1 solution (using sessions), but given the fact that
we're going to be working in a load-balanced environment with multiple
Tomcat instances, we are trying to use the session sparingly.

Another solution that I just thought of would be to replicate all the
values of the Form as hidden values on the JSP page so that they would
be repopulated on the submit.  This would be slightly annoying, but is a
viable solution.

My question is, is there another solution that works as clean as
sessions but uses the request?


_
Jeremy Nix
Senior Application Developer
Southwest Financial Services, LTD.
(513) 621-6699 x1158
www.sfsltd.com




RE: Passing ActionForm along on the request

2004-05-26 Thread None None
I presume the element that's throwing the NPE is one of the elements that 
the user cannot change.  I presume this because let's say for the sake of 
argument that all the fields of the ActionForm were on the screen, then what 
you describe should never happen.

Your dealing with the classic stateless nature problem of the web in 
general... you can either put it in session (or some other persistent 
storage on the server) or you can pass the information to the view, which 
wil pass it with the next request (i.e., hidden form fields, as you alluded 
to).

Putting any object in request definitively means that it should NOT persist 
between requests, that's the whole point, so if you have something you need 
to persist, as you do here, those are your choices basically, either session 
or data passing between JSPs.  If security is an issue you can get into 
applets or (God forbid!) ActiveX controls, then do all your data passing 
through them (and this might not even work with applets since they will 
probably be loading with each page load, so there's no persistence there 
either, so ActiveX becomes the option, but then your talking IE only, 
without buggy plug-ins anyway, so really neither is much of an option 
anyway).


From: Jeremy Nix [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Passing ActionForm along on the request
Date: Wed, 26 May 2004 10:35:41 -0400
Is it possible to call an Action which pre-populates a form, forwards on
to a JSP page which displays the form values for the user to change, and
then submit back to an Action that will contain the form value?  We're
running into a scenario where we prepopulate the Form in 1 action and
set it onto the Request.  The jsp displays some of the values so that
they may be modified, and then submits back to a second action where the
Form is to be populated.  When the form is submitted to the 2nd Action,
the ActionForm is reinitialized, and ends up throwing an exception in
the BeanUtils.populate method because an object on the form is null.
We've found that the scenario works fine when using Sessions, but runs
into issues when using the request.
Here's a sample struts config:
action
path=/actions/MyAction
type=actions.MyAction
name=myActionForm
scope=request
validate=false
forward name=continue path=/actions/MyAction.jsp/
/action
action
path=/actions/MyActionSubmit
type=actions.MyActionSubmit
name=myActionForm
scope=request
input=/actions/MyAction.jsp
validate=true
forward name=continue path=/actions/MyNextAction/
/action
We already have 1 solution (using sessions), but given the fact that
we're going to be working in a load-balanced environment with multiple
Tomcat instances, we are trying to use the session sparingly.
Another solution that I just thought of would be to replicate all the
values of the Form as hidden values on the JSP page so that they would
be repopulated on the submit.  This would be slightly annoying, but is a
viable solution.
My question is, is there another solution that works as clean as
sessions but uses the request?
_
Jeremy Nix
Senior Application Developer
Southwest Financial Services, LTD.
(513) 621-6699 x1158
www.sfsltd.com

_
MSN Toolbar provides one-click access to Hotmail from any Web page – FREE 
download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]