I know that works also.  It was not clear to me in your email that the example had to 
be specific to two different actions.  Anywho... here is what you were talking about.  
Right from my example code.  Free of charge, both the advice and the code. :-)

--- snip: shoppingcart.jsp ---
    <html:form action="/order.do">
      <html:hidden property="action" value="createOrder" />
        <html:submit>
           <bean:message key="button.createOrder"/>
        </html:submit>
    </html:form>

--- snip: shoppingcart.jsp ---

Note, I have different submit buttons on my page.

--- snip: struts-config.xml ---
    <!-- Process order request -->
    <action    path="/order"
               type="com.wrox.pjsp2.struts.order.OrderAction"
               name="orderForm"
              scope="session"
           validate="false"
              input="/order.jsp">
      <forward name="success"             path="/order.jsp"/>
      <forward name="thankyou"            path="/thankyou.jsp"/>
    </action>
--- snip: struts-config.xml ---

So like I said if you look at my example you can see that I also go to two different 
Actions from the same JSP page.  Yes, I use the same form bean, but that should not 
matter.  I believe that you could use different form beans, but I haven't checked it 
out yet.

Note, the reason for providing the example code at http://www.newparticles.com/struts 
was to go beyond the basic struts example and to provide what I learned back to the 
community.  Please download the example application.  I get no extra money for it.  
It's there as a resource to learn from.   

I've updated the code to work off CVS, but it's not been posted to the web site yet.

Steve
----- Original Message -----
From: Rustad, Aaron
Sent: Wednesday, February 06, 2002 4:22 PM
To: 'Struts Users Mailing List'
Subject: RE: Multiple Forms on one JSP...

Yes, I know that would work. However, I want BOTH on the same JSP, at the
same time. I don't want one action that decides what to do. I want each form
in the One JSP to submit to a different action.

Thanks for your help though.

-----Original Message-----
From: STEVE WILKINSON [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 06, 2002 2:57 PM
To: [EMAIL PROTECTED]
Subject: Re: Multiple Forms on one JSP...


I use multiple forms successfully in my sample application that I did in the

Wrox Pro JSP 2nd Edition book.  There is one per entry in the HTML table.

--- snip: from showshoppingcart.jsp ----

<html:form action="/checkout.do">
  <html:hidden property="action" value="update" />
  <html:hidden property="<%= Constants.TITLE_ID %>"
    value="<%= String.valueOf(titleId) %>" />
  <table cellspacing="2" cellpadding="2" border="0">
    <tr>
      <td>
        <bean:define id="quantity" name="cartItem" property="quantity"/>
        <html:text property="quantity"
           value="<%= String.valueOf(quantity) %>"
           size="5" maxlength="5"/>
      </td>
     <td>
       <html:submit>
         <bean:message key="button.update"/>
       </html:submit>
     </td>
   </tr>
  </table>
</html:form>

--- snip: from showshoppingcart.jsp ----

I iterate over a collection of items in the shopping cart and display the
table.  NOTE, each form has it's own submit button and that I use a hidden
variable to tell which form was submitted.

Here is the struts-config.xml file entry:

--- snip: from struts-config.xml file ----
    <!-- Process checkout request -->
    <action    path="/checkout"
               type="com.wrox.pjsp2.struts.shopping.CheckoutAction"
               name="checkoutForm"
              scope="request"
           validate="false">
      <forward name="success"             path="/shoppingcart.jsp"/>
    </action>
--- snip: from struts-config.xml file ----

Hopes this helps...

Source code from my chapter example can be downloaded from:
http://www.newparticles.com/struts

There is a new version being placed on the site that is based on the CVS
snapshot from December.  It's in the read me.  I will be updating this in
the next month or so to be current with CVS.

Thanks,
Steve Wilkinson

>From: "Rustad, Aaron" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
>Subject: Multiple Forms on one JSP...
>Date: Wed, 6 Feb 2002 13:15:53 -0700
>
>
>I seem to be running into a bit of a problem with one of my JSP pages that
>has two forms on it. Only one Form is being instantiated for it. I am sure
>you should be able to have multiple forms.
>
>Here is an example of my JSP:
>
><html:form action="/searchFood" >
>
><table width="224" border="0">
>
> ** FORM CODE **
>
></html:form>
><html:form action="/selectFood">
>
> ** MORE FORM CODE **
>
>   </html:form>
>
>However, only the Form bean associated with "/searchFood" is instantiated
>and placed in the session.
>
>Here is the entries I have in the struts-config.xml
>
> <action path="/searchFood"
> type="com.anassina.web.nutrition.SearchFoodAction"
> name="searchForm"
> scope="session"
> validate="false">
> <forward name="success" path="/nutrition/SearchFood.jsp"/>
> </action>
>
> <!-- Add selected Food -->
> <action path="/selectFood"
> type="com.anassina.web.nutrition.SelectFoodAction"
> name="selectedFoodForm"
> scope="session"
> validate="false">
> <forward name="success"
>path="/nutrition/FoodGroupList.jsp"/>
> </action>
>
>I would think that struts should handle this correctly.
>I am not receiving any errors with the exception of the JSP reference to
>the
>second bean isn't being found.
>
>
>Please advise.
>Thanks!
>Aaron.
>
>
>
>--
>To unsubscribe, e-mail:
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
><mailto:[EMAIL PROTECTED]>
>


_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


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

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

Reply via email to