This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes <s:select in <s:iterate tag displaying with comma seperated value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "<s:select in <s:iterate tag displaying with comma seperated value" Watch "<s:select in <s:iterate tag displaying with comma seperated value" New topic

<s:select in <s:iterate tag displaying with comma seperated value

Khyathi nyala

Joined: Sep 30, 2009
Posts: 5

I am having <s:select which contains 5 values inside the <s:iterator tag. Also, I have <s:button tag inside this iterator and button onClick event, calling the javascript function and inside this funciton setting up action and submitting. The code snippet as follows

So my page looks like the following:

queue name1 dropdown list savebutton

queuename2 dropdown list savebutton

I am accessing this setStatus of <s:select name attribute inside my action class. For example, when I click on first save button, the javascript funciton has been called and coming to the action class. Inside the action class when i try to print the "setStatus", i should get only queue name1 drop down value, But instead iam getting all the quename1, queuename2 drop down value with comma seperated. Can any one please help me how to get only the selected dropdown value of that pariticular submit.


Khyathi nyala
Ankit Garg

Joined: Aug 03, 2008
Posts: 9291

Khyathi please Use Code Tags when you post a source code. You can edit your message using button and then add code tags to it.

Your JSP code doesn't have a closing iterator tag so I'm assuming that it ends after the table tag. Also you didn't show the form tag so I'm assuming its before the iterator tag. In that case you are generating multiple drop down boxes with the same name, so when you submit the form, there'll be multiple values sent to the server with the name setStatus. To solve your problem, you'll have to use a String array as the setStatus property in your action. Alternatively you can move your form element inside the iterator tag, so that each select tag will be in a separate form thus when you submit, only one setStatus value will be sent to the server. In that case you'll have to change your javascript code a little. Your javascript code doesn't look too good to me anyways, why are you setting the form's action in javascript??

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Khyathi nyala

Joined: Sep 30, 2009
Posts: 5
Hi Ankit,

Thanks for the very quick reply. I do not have any form tag inside my jsp page. So should i use just <form: or <s:form. Can you please give me example for the <s:form to how exactrly use it. ?

For the javascript, i was doing in this way becaue i have the update method inside my action class and i am declaring some this like this to call the method inside the struts.xml

So when i say .submit, it directly calls this update method.

David Newton

Joined: Sep 29, 2008
Posts: 12617

You're trying to submit a form and you don't have any forms? I don't see how that will work.

Have you looked at the <s:form> tag documentation? It discusses how to use it. Oftentimes the documentation is one of the best first places to look for documentation.
I agree. Here's the link:
subject: <s:select in <s:iterate tag displaying with comma seperated value
Similar Threads
problem running dojo.plugin in struts2.1.6
struts 2.0 <s:select> tag problem
Struts 2
When Validation Error I Lose My Bean Value-Struts 2
how to delete multiple browse