You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Albrecht Berger <be...@gmx.ch> on 2002/07/15 12:33:03 UTC
using form-tag in iteration
Hello,
I want to implement a shoppingcart using the struts html:form tag and
logic:iterate.
In my JSP I have a List of products where every product should have its own
text input field for the quantity and its own submit button.
What would you recommend to solve this problem ?
Thx
berger
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: using form-tag in iteration
Posted by Albrecht Berger <be...@gmx.ch>.
>
> You're welcome to take a look at how we did it if you want to go digging.
> http://www.jcorporate.com/
>
> And the specific classes you'll want to peer into are:
> com.jcorporate.expresso.core.controller.Controller.java
> com.jcorporate.expresso.core.controller.Transition.java
> com.jcorporate.expresso.core.controller.State.java
>
Thx for your fast answer, I'm going to take a look at it.
Thx
Berger
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: using form-tag in iteration
Posted by Michael Rimov <ri...@centercomp.com>.
At 12:33 PM 7/15/2002 +0200, you wrote:
>Hello,
>I want to implement a shoppingcart using the struts html:form tag and
>logic:iterate.
>
>In my JSP I have a List of products where every product should have its own
>text input field for the quantity and its own submit button.
>
>What would you recommend to solve this problem ?
Berger,
In Expresso, what we did to solve that problem was to add the following for
each item button:
For each Item:
1 - Output the button and give it a name.... ex: item1
When the form is submitted if item1 was clicked then the parameter name
item1 will be included in the submit form so you can figure out which
button was submitted.
2 - Output a hiddenfield with name item1_params. [The parameters should be
properly encoded, of course]
When the form is submitted, once we know which button was pressed then we
grab any special parameters that we wanted associated with that button.
3 - and finally you'd want the text field to be item1_qty, so when you know
item1 button was pressed, you read the item1_qty parameter.
You're welcome to take a look at how we did it if you want to go digging.
http://www.jcorporate.com/
And the specific classes you'll want to peer into are:
com.jcorporate.expresso.core.controller.Controller.java
com.jcorporate.expresso.core.controller.Transition.java
com.jcorporate.expresso.core.controller.State.java
Where Controller is our mapping of our framework to the Struts Action
class, and Transition is the encapsulation of the button. And finally
State is as in a State in a State machine, and IIRC it contains some of the
parameter parsing code.
Anyway, the solution, although it looks weird seems to work well for our
apps where we have multiple transitions.
HTH!
-Mike
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>