final CrontabContainer crontab = new CrontabContainer("crontab", new PropertyModel<String>(reportTO,
"cronExpression"), reportTO.getCronExpression());
form.add(crontab);
final AjaxButton submit =
new ClearIndicatingAjaxButton("apply", new ResourceModel("apply"), getPageReference()) {
private static final long serialVersionUID = -958724007591692537L;
@Override
protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
ReportTO reportTO = (ReportTO) form.getModelObject();
reportTO.setCronExpression(StringUtils.hasText(reportTO.getCronExpression())
? crontab.getCronExpression()
: null);
try {
if (reportTO.getId() > 0) {
restClient.update(reportTO);
} else {
restClient.create(reportTO);
}
((BasePage) callerPageRef.getPage()).setModalResult(true);
window.close(target);
} catch (SyncopeClientCompositeErrorException e) {
LOG.error("While creating or updating report", e);
error(getString("error") + ":" + e.getMessage());
target.add(feedbackPanel);
}
}
@Override
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
target.add(feedbackPanel);
}
};
if (reportTO.getId() > 0) {
MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, xmlRolesReader.getAllAllowedRoles("Reports",
"update"));
} else {
MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, xmlRolesReader.getAllAllowedRoles("Reports",
"create"));
}
form.add(submit);
final AjaxButton cancel =
new ClearIndicatingAjaxButton("cancel", new ResourceModel("cancel"), getPageReference()) {
private static final long serialVersionUID = -958724007591692537L;
@Override
protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
window.close(target);
}
};
cancel.setDefaultFormProcessing(false);
form.add(cancel);
}