I've got a simple option class (as i've seen in examples)<p/>

public class Option {
        String key;
        String value;

        public String getKey() {
                return key;
        }

        public void setKey(String key) {
                this.key = key;
        }

        public String getValue() {
                return value;
        }

        public void setValue(String value) {
                this.value = value;
        }

        public Option(String key, String value) {
                this.key = key;
                this.value = value;
        }
}


I then populate an ArrayList (called imageList) with several entries of the
Option class.<p/>

Then I add a dropdownchoice component to my form using:
ChoiceRenderer choiceRenderer = new ChoiceRenderer("value", "key");
form.add(dropDownChoice = new DropDownChoice("imageCollectionId", 
imageList, choiceRenderer));

This works fine to display the key and value bits correctly in the html, but
then how do I get out the key and value properties.

The only way I've found so far is to have the imageCollectionId attribute in
my POJO business object of type Option, whereas I only want it to be of type
String - where it should just hold the 'key' value of the Option class.

All I want is to get at the 'key' value, but display the 'value' on the
screen.

Hope that makes some sense, it's been puzzling me all day, and I thought it
would be so simple.
Cheers

-- 
View this message in context: 
http://www.nabble.com/Newbie-can%27t-get-the-DropDownChoice-right-tf3492095.html#a9752792
Sent from the Wicket - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to