user746458
user746458

Reputation: 369

Multi select drop down in Wicket

How to implement multiple select drop down in Wicket. I am able to create multi select drop down view using bootstrap but I am not able to get how to relate selected options with IModel of drop down component? Is there any possibility in Wicket? I do not want to use ListMultipleChoice.

Upvotes: 4

Views: 2317

Answers (1)

JavaJ
JavaJ

Reputation: 23

Here is a sample code.

{
 private IModel<List<? extends String>> statusChoices;
 private DropDownChoice<String> status;
 private String statusFilter = "firstChoice";
 // List of Items in drop down
 statusChoices = new AbstractReadOnlyModel<List<? extends String>>() {
     @Override
     public List<String> getObject() {
         List<String> list = new ArrayList<String>();
         list.add("firstChoice");
         list.add("secondChoice");
         list.add("thirdChoice");
         return list;
     }
 };

 status = new DropDownChoice<String>("status",new PropertyModel<String>(this, "statusFilter"), statusChoices);
 status.add(new AjaxFormComponentUpdatingBehavior("onchange") {
     @Override
     protected void onUpdate(AjaxRequestTarget target) {
         if(statusFilter.equals("firstChoice"))
             // Do Somthing
         else
             // Do Somthing
      }
  });
}

Upvotes: 1

Related Questions