It's not a secret anymore!
The moose likes Struts and the fly likes Struts select tag problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts select tag problem" Watch "Struts select tag problem" New topic

Struts select tag problem

Devan Brahma
Ranch Hand

Joined: Jul 07, 2009
Posts: 46

i'm having a problem with the struts select tag.
the problem is that i'm not getting the key value
this is my code
<s:select list="couList" listKey="couid" headerKey="-1" headerValue="-Select-" name="misc.Country" onchange="countrychange()"></s:select>
in the list i provide the names
and in the listkey i provide the ids ...
now what i want is to get the id corresponding to the selected value..
please help

Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

Can you please clarify a bit what is in couList. Is it a list of some type of POJO class?? If yes, then can you please post the relevant code of that...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
vishwa venkat
Ranch Hand

Joined: Nov 22, 2003
Posts: 185
you should use select in this fashion-

<s:select list="couList" listKey="couid" listValue="couName" headerKey="-1" headerValue="-Select-" onchange="countrychange()"></s:select>
assuming couList is a list of Country Object having couid,couName as properties.
I agree. Here's the link:
subject: Struts select tag problem
jQuery in Action, 3rd edition