문제

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); 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top