item.add(field);
}
};
final AjaxButton userDetails = new IndicatingAjaxButton("userDetails",
new Model<String>(getString("userDetails"))) {
private static final long serialVersionUID = -4804368561204623354L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
editUserWin.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new ViewUserModalPage(ApprovalModalPage.this.getPageReference(), editUserWin,
userRestClient.read(formTO.getUserId())) {
private static final long serialVersionUID = -2819994749866481607L;
@Override
protected void closeAction(final AjaxRequestTarget target, final Form form) {
setResponsePage(ApprovalModalPage.this);
}
};
}
});
editUserWin.show(target);
}
};
MetaDataRoleAuthorizationStrategy.authorize(userDetails, ENABLE,
xmlRolesReader.getAllAllowedRoles("Users", "read"));
final AjaxButton submit = new IndicatingAjaxButton(APPLY, new Model<String>(getString(SUBMIT))) {
private static final long serialVersionUID = -958724007591692537L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
Map<String, WorkflowFormPropertyTO> props = formTO.getPropertyMap();
for (int i = 0; i < propView.size(); i++) {
@SuppressWarnings("unchecked")
ListItem<WorkflowFormPropertyTO> item = (ListItem<WorkflowFormPropertyTO>) propView.get(i);
String input = ((FieldPanel) item.get("value")).getField().getInput();
if (!props.containsKey(item.getModelObject().getId())) {
props.put(item.getModelObject().getId(), new WorkflowFormPropertyTO());
}
if (item.getModelObject().isWritable()) {
switch (item.getModelObject().getType()) {
case Boolean:
props.get(item.getModelObject().getId()).setValue(String.valueOf("0".equals(input)));
break;
case Date:
case Enum:
case String:
case Long:
default:
props.get(item.getModelObject().getId()).setValue(input);
break;
}
}
}
formTO.setProperties(props.values());
try {
restClient.submitForm(formTO);
((Todo) pageRef.getPage()).setModalResult(true);
window.close(target);
} catch (SyncopeClientCompositeErrorException e) {
error(getString(Constants.ERROR) + ":" + e.getMessage());
LOG.error("While submitting form {}", formTO, e);
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) {
window.close(target);
}
@Override
protected void onError(final AjaxRequestTarget target, final Form form) {
// nothing
}
};
cancel.setDefaultFormProcessing(false);
Form form = new Form(FORM);
form.add(propView);
form.add(userDetails);
form.add(submit);