简体   繁体   中英

onSelectionChanged wont work

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?

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); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM