File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes how to use html:submit to send value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to use html:submit to send value" Watch "how to use html:submit to send value" New topic
Author

how to use html:submit to send value

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hello, guys:

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)
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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
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[]).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use html:submit to send value