You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by th...@webmd.net on 2002/02/25 00:01:56 UTC

ActionForm scoping problems?

I have an action as such:
---
<action
        path="/enterBillingEdit"
        type="express.BillingIDActionForm"
        name="BillingIDForm"
.... Rest omitted to save space
---
and the form definition of:

<form-bean name="BillingIDForm" type="express.BillingIDForm" scope
="request"/>

And I have an entry point JSP which invokes actions and such....

I have a post
My BillingIDActionForm action simply loads data into the BillingIDForm and
saves an attribute in it.

The BillingIDActionForm::perform() then
calls return (mapping.findForward("success"));

Where success maps to:
<forward name="success" path="/BillIDForm.jsp"/>

The "submit" for BillIDForm.jsp is <html:form action
="/handleBillingIDSubmit.do">
where handleBillingIDSubmit maps to:
<action
        path="/handleBillingIDSubmit"
        type="express.BillingIDFormSubmitAction"
        name="BillingIDForm"
        scope="request"
---

In the perform method for: BillingIDFormSubmitAction,
public ActionForward perform(ActionMapping mapping,      ActionForm form,
etc..)
when I retrieve the variable form and cast it to: BillingIDForm, the value
I set in the previous action is completely gone.   In this case, it's back
to null which tells me that a "new" instance of the BillingIDForm was
created in-between my last action this action.....      I thought the whole
purpose of "request scope" was to retain the same instance of a form or
bean all the way thru from the entry request to the end of the request....
It does not appear to be the case...

Is there any other decent examples or explanations on when form variables
descope themselves between requests?    If I go and change all of my
"scope" attributes in the struts.config.xml to "session", my application
works fine.    Trouble is that I want it to work with "request" scope.    I
think I am definitely missing a key point here somewhere!

I'm sorry, but I'm just not getting it  :-)

thanks,
Theron















--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: ActionForm scoping problems?

Posted by Tim Sawyer <ts...@nildram.co.uk>.
Have you implemented the reset() method on the action form?  I found that
struts calls reset more often than you would expect.

Tim.

-----Original Message-----
From: theron.kousek@webmd.net [mailto:theron.kousek@webmd.net]
Sent: Sunday, February 24, 2002 11:02 PM
To: Struts Users Mailing List
Subject: ActionForm scoping problems?



I have an action as such:
---
<action
        path="/enterBillingEdit"
        type="express.BillingIDActionForm"
        name="BillingIDForm"
.... Rest omitted to save space
---
and the form definition of:

<form-bean name="BillingIDForm" type="express.BillingIDForm" scope
="request"/>

And I have an entry point JSP which invokes actions and such....

I have a post
My BillingIDActionForm action simply loads data into the BillingIDForm and
saves an attribute in it.

The BillingIDActionForm::perform() then
calls return (mapping.findForward("success"));

Where success maps to:
<forward name="success" path="/BillIDForm.jsp"/>

The "submit" for BillIDForm.jsp is <html:form action
="/handleBillingIDSubmit.do">
where handleBillingIDSubmit maps to:
<action
        path="/handleBillingIDSubmit"
        type="express.BillingIDFormSubmitAction"
        name="BillingIDForm"
        scope="request"
---

In the perform method for: BillingIDFormSubmitAction,
public ActionForward perform(ActionMapping mapping,      ActionForm form,
etc..)
when I retrieve the variable form and cast it to: BillingIDForm, the value
I set in the previous action is completely gone.   In this case, it's back
to null which tells me that a "new" instance of the BillingIDForm was
created in-between my last action this action.....      I thought the whole
purpose of "request scope" was to retain the same instance of a form or
bean all the way thru from the entry request to the end of the request....
It does not appear to be the case...

Is there any other decent examples or explanations on when form variables
descope themselves between requests?    If I go and change all of my
"scope" attributes in the struts.config.xml to "session", my application
works fine.    Trouble is that I want it to work with "request" scope.    I
think I am definitely missing a key point here somewhere!

I'm sorry, but I'm just not getting it  :-)

thanks,
Theron















--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: ActionForm scoping problems?

Posted by Robert Nocera <rn...@neosllc.com>.
This could be off-base, but I think you'll have better results if you
change the case of your form-bean variable name from "BillingIDForm" to
"billingIDForm".  I think it may be using a static class BillingIDForm
and not creating an instance of the class.  Change all references on the
JSP page to "billingIDForm" and the <form-bean name="billingIDForm" ...

I know I had a similar problem a while back and it seemed that making
that change fixed it.

Robert Nocera
New England Open Solutions
www.neosllc.com
"You supply the vision, we'll do the rest."
 

-----Original Message-----
From: theron.kousek@webmd.net [mailto:theron.kousek@webmd.net] 
Sent: Sunday, February 24, 2002 6:02 PM
To: Struts Users Mailing List
Subject: ActionForm scoping problems?


I have an action as such:
---
<action
        path="/enterBillingEdit"
        type="express.BillingIDActionForm"
        name="BillingIDForm"
.... Rest omitted to save space
---
and the form definition of:

<form-bean name="BillingIDForm" type="express.BillingIDForm" scope
="request"/>

And I have an entry point JSP which invokes actions and such....

I have a post
My BillingIDActionForm action simply loads data into the BillingIDForm
and
saves an attribute in it.

The BillingIDActionForm::perform() then
calls return (mapping.findForward("success"));

Where success maps to:
<forward name="success" path="/BillIDForm.jsp"/>

The "submit" for BillIDForm.jsp is <html:form action
="/handleBillingIDSubmit.do">
where handleBillingIDSubmit maps to:
<action
        path="/handleBillingIDSubmit"
        type="express.BillingIDFormSubmitAction"
        name="BillingIDForm"
        scope="request"
---

In the perform method for: BillingIDFormSubmitAction,
public ActionForward perform(ActionMapping mapping,      ActionForm
form,
etc..)
when I retrieve the variable form and cast it to: BillingIDForm, the
value
I set in the previous action is completely gone.   In this case, it's
back
to null which tells me that a "new" instance of the BillingIDForm was
created in-between my last action this action.....      I thought the
whole
purpose of "request scope" was to retain the same instance of a form or
bean all the way thru from the entry request to the end of the
request....
It does not appear to be the case...

Is there any other decent examples or explanations on when form
variables
descope themselves between requests?    If I go and change all of my
"scope" attributes in the struts.config.xml to "session", my application
works fine.    Trouble is that I want it to work with "request" scope.
I
think I am definitely missing a key point here somewhere!

I'm sorry, but I'm just not getting it  :-)

thanks,
Theron















--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>