This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes how to get the selected value from a drop down to action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to get the selected value from a drop down to action" Watch "how to get the selected value from a drop down to action" New topic
Author

how to get the selected value from a drop down to action

rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
I have a list of values in a dropdoen box, I am using struts 2.0 and using the select tag as explained below,


Can anyone advise how to get the selected value to the action. I tried with a getter of strUserName but it is not working. Is there any other way?
a kishore
Ranch Hand

Joined: Sep 16, 2009
Posts: 82
Hi Rahul,

Im using the following method,



where 'selectedcountry' is one of the property in actionform..

-HTH

regards,
kishore
vishnu priya
Greenhorn

Joined: Nov 06, 2009
Posts: 13
hi i am using struts2 select tag for a dropdown list
after selecting a particular element i need to display that selected value in another jsp

my select tag is
<s:select name="country" label="Country" headerKey="3" headerValue="---Select One---" list="country"/>

how can i get the selected value?
Dave Whaley
Greenhorn

Joined: Aug 07, 2003
Posts: 5
rahulJ james wrote:I have a list of values in a dropdoen box, I am using struts 2.0 and using the select tag as explained below,

...there any other way?


Why aren't you using the struts2 tag library (select tag ref) ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

He is--just using a very confusing and misleading taglib prefix.
rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
What am I missing in my code, Can anyone advise. I am using the struts2 tag. I dont find property attribute for select tag.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Because you were using a confusing and misleading tag prefix, one responder assumed you were using Struts 1. Which version of Struts are you using? If you're using Struts 2, as your attributes imply, I'd *strongly* urge you to use the default taglib prefix to avoid confusion. Not to mention that the "html" prefix doesn't make any sense for S2, since there are many tags that don't emit any HTML markup.

You need a *setter* for the property--not a getter. OGNL can't use a getter to set a value.
 
jQuery in Action, 2nd edition
 
subject: how to get the selected value from a drop down to action