wood burning stoves 2.0*
The moose likes Struts and the fly likes Passing parameters to the next action using html:button or html:submit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Passing parameters to the next action using html:button or html:submit" Watch "Passing parameters to the next action using html:button or html:submit" New topic
Author

Passing parameters to the next action using html:button or html:submit

Sunitha Mudidani
Greenhorn

Joined: Apr 25, 2006
Posts: 28
Hi ,

I have a jsp where a list of customers will be displayed in table. Each row in the table has a button that enables to view the customer details.
The table rows are displyed by iterating through a list which holds each customer row information(different from the customer details to be displayed).

My problem is how do I pass the customer id to the next action which gets invoked when the button is pressed. The customer id values are available as a bean property.

I need to work on this soon.. so pls respond asap.

Thanks
Sunitha
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I'd suggest you use a link rather than a button. With a link, you can simply pass a parameter. Something like this:

<html:link action="/customerDetails" paramId="custId" paramName="customer" paramProperty="id" >customer details</html:link>


Merrill
Consultant, Sima Solutions
Sunitha Mudidani
Greenhorn

Joined: Apr 25, 2006
Posts: 28
I have to use a button instead of a link .. it is according to the design.
Any suggestions pls.
Can it be worked out using a java script function?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If it has to be a button, here are some options:
  • Make the onclick event of the button execute the link using the JavaScript location.replace(URL)
  • Embed a custom image you've created that looks like a button in the link. That way it looks like a button, but it's really a link
  • Leave it as a regular submit button, but make a separate <html:form> for each row of the table. Then put the ID field in an <html:hidden> field just before the submit button
  •  
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Passing parameters to the next action using html:button or html:submit