Class<?> permissionClass = permissionTypeModel.getObject();
user.getPermissions().add(new PermissionInput(permissionClass, values, State.NEW));
} else {
permissionInput.setState(State.UPDATED);
}
editorPanel.replaceWith(new EmptyPanel("permissionEditor"));
submitButton.setVisible(false);
target.add(container);
afterSubmit(target, form);
LOGGER.info("got values {}", values.toString());
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
LOGGER.warn("Error occured during submit of form via submitButton");
}
};
form.add(submitButton);
submitButton.setVisible(!createMode);
permissionTypeChoice =
new DropDownChoice<Class<?>>("permissionTypeSelect", permissionTypeModel, permissionTypeListModel) {
private static final long serialVersionUID = -9044237781077496289L;
@Override
public boolean isVisible() {
return createMode;
}
};
permissionTypeChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
private static final long serialVersionUID = 5195539410268926662L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
LOGGER.info("selected + " + permissionTypeModel.getObject());
BeanEditorPanel beanEditorPanel =
new BeanEditorPanel("permissionEditor", permissionTypeModel.getObject(), values);
editorPanel.replaceWith(beanEditorPanel);
editorPanel = beanEditorPanel;
submitButton.setVisible(true);
target.add(container);
}
});
form.add(permissionTypeChoice);
if (createMode) {
editorPanel = new EmptyPanel("permissionEditor");
} else {
editorPanel =
new BeanEditorPanel("permissionEditor", permissionInput.getType(), permissionInput.getValues());
}