• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to add parameters to the action dynamically

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a shopping cart application, for this can show the list of the products with the following way

Product Image | SKU | Price | QTY (textbox) | Add to Cart (hyperlink)


Here, when we click on the Add To Cart link, I'm calling an action and adding the item to the cart (session), here I can get the ProductNumber and price as parameters (because they are from collection object. but how can I get the quantity parameter (it is dynamic values added by user). I'm not getting how to grab that value into my action class.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're basically implementing a form without an actual form? (Why *aren't* you using a form--it'd make your requirement substantially easier.) Also, if you're not in a form, using the <html:text...> tag is probably a Bad Idea, as it expects an ActionForm to be in scope.

If you're dead-set on doing things this way I'd probably recommend implementing a link "onclick" handler that takes the link as it is, adds the quantity, and return true so the link will be followed.
 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

I got the same idea to use onClick event and call the action in the javascript function, but I'm not getting the idea to add the quantity field in the onClick's javascript function.
 
I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic