Wicket DropDownChoice read-only

318 views Asked by At

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

There are 3 answers

0
martin-g On

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.

1
AudioBubble On

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
soorapadman On

Try to use attribute modifier will do that for you

dropdown.add(new AttributeModifier("disabled", "true");