On 3/25/2011 1:54 PM, Jered Myers wrote:
You can create a simple PropertyModel to hold the value your form is trying to set. Here is an example:

public  Pageextends  WebPage {
   private  List letters = Arrays.asList(new  String[] {"A","B","C"  }));
   public  String  selected ="B";

   public  Page() {
     Form form =new  Form("form");
DropDownChoice choice=new DropDownChoice("ddc",new PropertyModel(this,"selected"), letters);
   }
}

The example is from: https://cwiki.apache.org/WICKET/dropdownchoice-examples.html. It is missing the generics if you are working in 1.4.x, but it demonstrates the process well. The model object here is the "selected" string. When the form saves it will set the "selected" string with the value in the drop down.

Ah. I get it. Thank you Jered.

As a side question then, does this mean that the example cited in the
DropDownChoice javadoc does not work? Because it only did:


    form.add(new DropDownChoice("site", SITES));

So wouldn't it fail the same way?

/jg

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to