Question

I use wicket and I have created a List Choice like this and overriden onSelectionChanged:

   ListChoice<String> hotelList = new ListChoice<String>("hotel",
           new PropertyModel<String>(this, "selectedHotel"), hotelLabels)   {
      @Override
      protected void onSelectionChanged(String newSelection)
      {
         super.onSelectionChanged(newSelection);
         System.out.print("Tesy");
      }

   };

but it did not work - program never fires this method. I do not want use onSubmit to handle this. I need action when someone clicked smth on list.

How to do this in wicket?

Was it helpful?

Solution

final ListChoice<String> hotelList = new ListChoice<String>("hotel", new PropertyModel<String>(this, "selectedHotel"), hotelLabels);
hotelList.add(new AjaxFormComponentUpdatingBehavior("onchange") {
  protected void onUpdate(AjaxRequestTarget target) {
    System.out.print(hotelList.getModel().getObject());
  }
});
hotelList.setOutputMarkupId(true); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top