I have a DropDownChoice
with two OnChangeAjaxBehavior
s on it. When i select the value 2 which should set to DropDownChoice
disabled it get's for a second disable before it shows me the AccessDeniedPage
and in the server logs i see a ListenerNotAllowedInvocationException
. Have this in Wicket 6 and 7.
Any idea how to fix this?
Code below:
private Integer selected;
public HomePage(final PageParameters parameters) {
super(parameters);
final DropDownChoice<Integer> ddc = new DropDownChoice<Integer>("ddc", new PropertyModel(this, "selected"), Arrays.asList(1,2,3)){
@Override
protected void onConfigure() {
super.onConfigure();
setEnabled(!Objects.equals(getModel().getObject(), 2));
}
};
ddc.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget art) {
art.add(getComponent());
saveToDb(model.getObject);
}
});
ddc.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget art) {
art.add(getComponent(), otherComponent);
}
});
ddc.setOutputMarkupId(true);
add(ddc);
}
I have tried disabling one of the behaviors with the same condition as the component, but i did not work.
@Override
public boolean isEnabled(Component component) {
return !Objects.equals(component.getDefaultModelObject(), 2);
}
Or like this:
@Override
public boolean isEnabled(Component component) {
return component.isEnabled();
}