[Wicket-user] DropDownChoice and Value ID

2006-08-18 Thread Johannes A. Kaefer
Hi everyone,

I have the following problem:

I supply the DropDownChoiceElement with a List containing HashMap's. So
every Listelement is a HashMap. The HashMap contains a association
between ID's and Names (the ID's are primary key whereas the Names are
not). Don't bother about the problem that then there might be duplicate
entries in the DropDownChoice.

I succesfully manage to create the html-code right, thru suppling an
IChoiceRenderer. However: how do I get the selecte Value-ID from the
DropDownChoice-Element. All I manage to get is a String containing the
Name and the ID.

Thanks for your help.
  jak4

-
Here is the Code (it's from the examples so there isn't anything new
about it, except the HashMap):

// every Listelement contains a HashMap
List names = getListFromDB();

add(new DropDownChoice(userSelect, names, new IChoiceRenderer(){
   public String getDisplayValue(Object object) {
return ((String)((HashMap) object).get(lastname));
   }

   public String getIdValue(Object object, int index) {
// avoid accessing the element -1, which is Choose Element
if( index = 0)
 return((Integer)((HashMap)names.get(index)).get(id)).toString();
else
 return -1;
   }
}));




signature.asc
Description: OpenPGP digital signature
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] DropDownChoice and Value ID

2006-08-18 Thread Eelco Hillenius
 I succesfully manage to create the html-code right, thru suppling an
 IChoiceRenderer. However: how do I get the selecte Value-ID from the
 DropDownChoice-Element. All I manage to get is a String containing the
 Name and the ID.

Typically, you should do that via your model. The drop down component
uses and updates the model for the current selection. So e.g.
myDropDown.getModelObject() or a query directly on the model you
passed in should get you the current selection without you having to
fool around with the id and display values.

Eelco

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user