0

I have a Wicket DropDownChoice and I am trying to avoid using Ajax methods. After the selection of a value I want the selection to be read-only and the user not be able to change it again.

final DropDownChoice<Pet> dropdown = new DropDownChoice<Pet>("dropdown",
                new PropertyModel<Pet>(this, "selected"), list, choiceRenderer) {
// code here
}

3 Answers3

0

If you want to avoid using Ajax (i.e. using Wicket) to make it read-only then you should do it with custom JavaScript. E.g. using jQuery:

jQuery('#petDropdown').change(jQuery(this).attr('disabled', 'disabled'));

i.e. set disabled="disabled" attribute to the HTMLSelectElement on the first change event.

martin-g
  • 17,243
  • 2
  • 23
  • 35
0

It seems that it is not possible to make the dropdown "read-only" without using Ajax or jQuery. I am not happy with that and i will find an alternative solution. Thank you anyway for your help

0

Try to use attribute modifier will do that for you

dropdown.add(new AttributeModifier("disabled", "true"); 
soorapadman
  • 4,451
  • 7
  • 35
  • 47