Jay,

You are correct in that the JSP snip was not complete.  This is contained in an 
iterate tag.  I mentioned that after the code snip.   

Multiple forms do work in struts.  I have sample code that shows it.  Sometimes while 
debugging a problem its easier to look at working code and see what they do 
differently.

Thanks for your response, code snip below:

Steve


--- bigger snip: shoppingcart.jsp -----

<logic:iterate id="cartItem"  
             type="com.wrox.pjsp2.struts.common.CartItem"  
             name="shoppingCart"
         property="cartItems">
<%
  num++;
  if((num % 2) == 0) {
    bgColor = SLATE;
  } else {
    bgColor = WHITE;
  }
%>
  <bean:define id="cd" name="cartItem" property="cd" 
type="com.wrox.pjsp2.struts.common.CD"/>
        <tr bgcolor="<%= bgColor %>">
            <td><jsp:getProperty name="cd" property="artist"/></td>
            <td><jsp:getProperty name="cd" property="titleName"/></td>
            <td><jsp:getProperty name="cd" property="price"/></td>
            <td valign="middle">
              <html:form action="/checkout.do">
                <html:hidden property="action" value="update" />
                <bean:define id="titleId" name="cd" property="titleId"/>
                <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>
            </td>
            <td><jsp:getProperty name="cartItem" property="total"/></td>
        </tr>
</logic:iterate>

--- bigger snip: shoppingcart.jsp -----



----- Original Message -----
From: Jay Sissom
Sent: Thursday, February 07, 2002 2:59 AM
To: Struts Users Mailing List
Subject: Re: Multiple Forms on one JSP...

Maybe this code snippet is not complete, but there is only one FORM on this
page.  Everything between <html:form> and </html:form> is a single form.
There may be multiple <html:submit> tags, but there is only one FORM.

I don't believe struts will work with multiple-forms, but I'm not sure.
Multiple submit buttons is no problem.

Jay

----- Original Message -----
From: "STEVE WILKINSON" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 06, 2002 4:56 PM
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