You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Minnie <st...@minniebyte.com> on 2002/11/26 19:46:03 UTC

Action mappings

Maybe I am missing something, but.....

I have a customer form (CustomerView.do) that takes a HTTP GET parameter to
show a customer.  (ie. CustomerView.do?customerid=4).  On this customer
form, there are links to JSP pages to modify the data of the customer.  If I
wanted to add a phone number, then I would call addcustomerphonenumber.jsp.
The AddCustomerPhoneNumber.do action mapping is as follows:

 <action path="/AddCustomerPhoneNumber" type="GetCustomerPhoneNumberAction"
      name="customerPhoneNumberForm" scope="request" validate="false">
      <set-property property="loginRequired" value="true"/>
      <forward name="success" path="/addcustomerphonenumber.jsp"/>
      <forward name="error" path="/CustomerView.do" redirect="true"/>
 </action>

This action populates the customer form (puts a hidden input field
containing the customer number "4") and the addcustomerphonenumber.jsp is
displayed. When the user SUBMITS the addcustomerphonenumber.jsp the
SaveAddedCustomerPhoneNumber action is called.

<action path="/SaveAddedCustomerPhoneNumber"
      type="SaveAddedCustomerPhoneNumberAction"
name="customerPhoneNumberForm"
      scope="request" input="/addcustomerphonenumber.jsp" validate="false">
      <set-property property="loginRequired" value="true"/>
      <forward name="success" path="/CustomerView.do"/>
      <forward name="error" path="/addcustomerphonenumber.jsp"/>
</action>

MY PROBLEM IS:
This saves the customer phone number, but I get an error that the customer
bean is not found in the scope null.  This is because the "success" forward
is forwarding to /CustomerView.do with NO GET PARAMETER.  Since this get
parameter is dynamic depending upon the customer, how do I return to the
CustomerView.do?customerid=4 ????

Struts is designed to have the action mappings make the MVC design be
easier.  Do I manually have to put code into
SaveAddedCustomerPhoneNumber.java to have the servlet forward the request
back to the HTTP referrer?  I would be surprised is STRUTS does not have a c
lean method to handle something like this.

Thanks for any help in advance.

Mark

Re: Action mappings

Posted by Gemes Tibor <ge...@regens.hu>.
2002-11-26, k keltezéssel Mark Minnie ezt írta:
> This saves the customer phone number, but I get an error that the customer
> bean is not found in the scope null.  This is because the "success" forward
> is forwarding to /CustomerView.do with NO GET PARAMETER.  Since this get
> parameter is dynamic depending upon the customer, how do I return to the
> CustomerView.do?customerid=4 ????

I solve this kind of problem with session scope beans. The CustomerView
action will read from the appropriate ActionForm which is in session
scope, so untill you change the customerid it will be remembered across
requests.

Hth,

Tib


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