On 2/27/07, Jason Roelofs <[EMAIL PROTECTED]> wrote:

Why can't I have:

add(new DropDownChoice("gated", model, {"AND", "OR"},  {"&", "|"});

or better yet:

add(new DropDownChoice("gated", model, { {"&", "AND"}, {"|", "OR"}});


you can

class mydropdownchoice extends dropdownchoice {
 public mydropdownchoice(id, model, final object[] choices) {
      super(id, model);
      arraylist choiceslist=new arraylist();
      for (int i=0;i<choices.length;i++) {
            choiceslist.add(choices[i][0]);
      }
      setchoices(choiceslist);
      setrenderer(new ichoicerenderer() {
          Object getDisplayValue(Object object) {
                return choices[getchoices().indexof(object)][1];
           }
           String getIdValue(T object, int index) { return object; }
       }
}

or something very close to that.

what you have to realize is that your usecase is not very representative of
whats out there.

one, you have only a few choices
two, your list of choices is hardcoded
three, you dont mind keeping those choices and their values in session

these three things are not true for most usecases ive come across

most usecases you have a list of objects, like Person, that you load from
the database. you dont know how many, and you dont want to keep the list in
session. dropdownchoice is optimized for that usage:

add(new dropdownchoice("people", model, new LoadableDetachableModel() {
load() { return db.loadpeople(); }, new ChoiceRenderer("personId",
"fullName"));

this also happens to be the most "generic" form. nothing stops you from
subclassing and optimizing the usage for your usecases

-igor
-------------------------------------------------------------------------
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