this.createFlag = roleTO.getId() == 0;
if (!createFlag) {
originalRoleTO = AttributableOperations.clone(roleTO);
}
final Form form = new Form("RoleForm");
add(new Label("displayName", roleTO.getId() == 0 ? "" : roleTO.getDisplayName()));
form.setModel(new CompoundPropertyModel(roleTO));
this.rolePanel = new RolePanel("rolePanel", form, roleTO, mode, getPageReference());
form.add(rolePanel);
final AjaxButton submit = new IndicatingAjaxButton("submit", new ResourceModel("submit")) {
private static final long serialVersionUID = -958724007591692537L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
try {
submitAction(target, form);
if (pageRef.getPage() instanceof BasePage) {
((BasePage) pageRef.getPage()).setModalResult(true);
}
closeAction(target, form);
} catch (Exception e) {
error(getString("error") + ":" + e.getMessage());
target.add(feedbackPanel);
}
}
@Override
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
target.add(feedbackPanel);
}
};
final AjaxButton cancel = new IndicatingAjaxButton("cancel", new ResourceModel("cancel")) {
private static final long serialVersionUID = -958724007591692537L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
closeAction(target, form);
}
};
cancel.setDefaultFormProcessing(false);
MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, xmlRolesReader.getAllAllowedRoles("Roles",
createFlag
? "create"
: "update"));
form.add(submit);
form.setDefaultButton(submit);
form.add(cancel);
add(form);
}