• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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.
 
sunglasses are a type of coolness prosthetic. Check out the sunglasses on this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic