Skip to content

Instantly share code, notes, and snippets.

@koalahamlet
Created February 4, 2014 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koalahamlet/8814660 to your computer and use it in GitHub Desktop.
Save koalahamlet/8814660 to your computer and use it in GitHub Desktop.
button
/* SEND BUTTON */
AjaxSubmitLink sendButton = new AjaxSubmitLink("sendButton", form) {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target, Form form) {
target.appendJavascript("newInvitationPage.clearFeedbackIndicators();");
setObservee(observation);
if (validateObservation(false, target)) { // false == clicked send
// Page is valid, save first:
saveObservation();
// The user will leave the page by clicking a confirm button
String confirmMessage = generateConfirmationMessage();
target.appendJavascript("confirmationDialog.showDialog('"
+ confirmMessage + "');");
} else {
onError(target, form);
}
}
@Override
protected void onError(AjaxRequestTarget target, Form form) {
super.onError(target, form);
target.addComponent(feedbackPanel);
target.appendJavascript("initModalFeedback(); " +
"newInvitationPage.setExitConfirm(true);");
target.appendJavascript(createOnErrorFeedbackIndicatorJavascript());
}
};
add(sendButton.setVisible(newInvitationService.isSendButtonVisible(observation, observerRequest)));
// Hide the send button for live observation since the teacher doesn't have to add/share anything
if (observation.isLive()) {
sendButton.setVisible(false);
}
String sendButtonText = newInvitationService.isAcknowledgeButtonNeeded(observation, observerRequest)
? "Acknowledge" : "Send";
Label sendButtonLabel = new Label("sendButtonLabel", sendButtonText);
sendButton.add(sendButtonLabel);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment