OK, I found a solution. Maybe some of you can shed some light on why this
works.

In my second <html:form>, I simply included type="com.class.name" to signify
the class that should be instantiated in the event that it doesn't locate
one. However, Doesn't the ActionServlet look at the ActionMappings to
determine what Form to instantiate? I know it does for the first form in my
JSP and for any other single-formed JSP. Could this be a bug?

In any case, much thanks to Steve for your help.
Thanks!
Aaron.



-----Original Message-----
From: STEVE WILKINSON [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 07, 2002 7:23 AM
To: Struts user
Subject: Re: Multiple Forms on one JSP...


Sounds like you need some debugging of you code.  Hum, I don't see
enough posted here to help.   

Normally, one would post more code or look at the code sample that was
offered to compare and see what's wrong.  I don't think I can help
anymore.   

What I was trying to say with my prior posts is that it is possible.
Obviously, this is not the help you need.  There are other things to
look at, but it appears that my help is not wanted or needed.  If you
want to post more information maybe you can entice others to look with
your charming responses.  Good luck debugging your code.  


----- Original Message -----
From: Rustad, Aaron
Sent: Wednesday, February 06, 2002 8:22 PM
To: 'Struts user '
Subject: RE: Multiple Forms on one JSP...

Alright, this is not what I want.

I have ONE JSP, it contains TWO forms, each form goes to a separate
action.
However, when the JSP is rendered, the first form's FormBean is placed
in
the session, but the second form(same JSP) throws a JSPException
indicating
that it cannot find a bean under that name.

I am sure that you should be able to have TWO forms, referencing two
different actions, using TWO different formBean.

Any suggestions?
AR.

-----Original Message-----
From: STEVE WILKINSON
To: Struts user
Sent: 2/6/02 4:39 PM
Subject: Re: Multiple Forms on one JSP...

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]>

--
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