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

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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:

<table>
queue name1 dropdown list savebutton
</table>

<table>
queuename2 dropdown list savebutton
</table>



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.

Thanks.
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Khyathi nyala
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Thanks.
 
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 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.

http://struts.apache.org/2.1.8/docs/form.html
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic