How should I do if I want to send a selected value once submit button is clicked?
Here is the scenario: I have a logic:iterate tag looping through and display a collection of rows, there is a html:submit button at the end of each row. If I want to send a property of a specific row once button is clicked, how should I do?
I tried property attribute of html:submit: html:submit property="title" ... (title is property of a row)
But it only send over button value -"Get".
Greatly appreciate any input.
(sorry, I could not post for detailed code because of posting errors)
Well, clicking any button will submit the entire form and include the <buttonName>=<buttonText> as a parameter.
Assuming that you don't use crazy Javascript tricks: If your buttons all have the same <buttonText> (Get), they will have to have different <buttonName>s. Otherwise there's no way to tell them apart.
Try using indexes on the names. Note that your getGet(String) method will need to change to getGet(String[]).
A good workman is known by his tools.
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
Thanks. I am trying to know which button is clicked, but which associated row was chosen.
What I am asking is actually to achieve what html:link can do.
For html:link, we can use paramName, paramProperty to send over a property value of a specific row of a collection using getParameter() method. Can html:submit do the same? I know its a tough question since I have not seen anyone do this or given an clear answer.
I am wondering if Struts actually does not add the same functionality to html:submit as to html:link. A negligence?
Originally posted by Marc Peabody: Well, clicking any button will submit the entire form and include the <buttonName>=<buttonText> as a parameter.
Assuming that you don't use crazy Javascript tricks: If your buttons all have the same <buttonText> (Get), they will have to have different <buttonName>s. Otherwise there's no way to tell them apart.
Try using indexes on the names. Note that your getGet(String) method will need to change to getGet(String[]).