struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Rimov <rim...@centercomp.com>
Subject Re: using form-tag in iteration
Date Mon, 15 Jul 2002 10:52:48 GMT
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:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message