}
}
private void addButtons() {
AjaxButton okButton = new AjaxButton(ID_OK_BUTTON, new ResourceModel("okLabel")) {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target, Form<?> form) {
boolean succeeded = actionExecutor.executeActionAndProcessResults(target, form);
if(succeeded) {
// the Wicket ajax callbacks will have just started to hide the veil
// we now show it once more, so that a veil continues to be shown until the
// new page is rendered.
target.appendJavaScript("isisShowVeil();\n");
send(getPage(), Broadcast.EXACT, new IsisActionCompletedEvent(getActionModel(), target, form));
target.add(form);
} else {
if (actionPromptIfAny != null) {
final StringBuilder builder = new StringBuilder();
// ensure any jGrowl errors are shown
// (normally would be flushed when traverse to next page).
String errorMessagesIfAny = JGrowlUtil.asJGrowlCalls(IsisContext.getMessageBroker());
builder.append(errorMessagesIfAny);
// append the JS to the response.
String buf = builder.toString();
target.appendJavaScript(buf);
target.add(form);
}
}
};
/**
* On validation error
*/
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
super.onError(target, form);
target.add(form);
}
};
okButton.add(new JGrowlBehaviour());
add(okButton);
AjaxButton cancelButton = new AjaxButton(ID_CANCEL_BUTTON, new ResourceModel("cancelLabel")) {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(final AjaxRequestTarget target, Form<?> form) {
if(actionPromptIfAny != null) {
actionPromptIfAny.closePrompt(target);
}
}
};
// so can submit with invalid content (eg mandatory params missing)
cancelButton.setDefaultFormProcessing(false);
add(cancelButton);
// TODO: hide cancel button if dialogs disabled, as not yet implemented.
if(ActionPromptModalWindow.isActionPromptModalDialogDisabled()) {
cancelButton.setVisible(false);
}
}