Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
rahulJ james
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul,

Im using the following method,



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

-HTH

regards,
kishore
 
vishnu priya
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He is--just using a very confusing and misleading taglib prefix.
 
rahulJ james
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic