There should not be any confirmation message when the input data in the auto complete component is invalid.

This commit is contained in:
Tom Vahlman 2012-03-24 12:13:35 +01:00
parent 38183ae1d3
commit 1a363128ac
2 changed files with 52 additions and 19 deletions
src/main/java/se/su/dsv/scipro/admin/panels

@ -74,7 +74,7 @@ public class ManualMatchPanel extends Panel {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
if(testACInputString(autoCompleteObjectField)) {
Session.get().error("No match could be created because the data was invalid.");
Session.get().error("No match could be created because the input was invalid.");
target.addComponent(localFeedback);
} else {
matchModel.getObject().setSupervisor(autoCompleteObjectField.getModelObject() != null ? autoCompleteObjectField.getModelObject():null);
@ -92,6 +92,11 @@ public class ManualMatchPanel extends Panel {
super.onError(target, form);
target.addComponent(feedbackPanel); // is only activated on "this"
}
@Override
protected boolean isDisplayConfirmation() {
return saveButton.getMessageContentHTML() != null && !saveButton.getMessageContentHTML().isEmpty();
}
};
}
@ -145,7 +150,7 @@ public class ManualMatchPanel extends Panel {
//noinspection unchecked
autoCompleteObjectField.setModelObject(null);
autoCompleteObjectField.clearInput();
saveButton.setMessageContentHTML("No supervisor was selected.");
saveButton.setMessageContentHTML(null);
target.addComponent(currentFragment);
target.addComponent(autoCompleteObjectField);
target.addComponent(saveButton);
@ -243,11 +248,11 @@ public class ManualMatchPanel extends Panel {
/**
*
* This method is used to return a match message that an employee was matched or suggested to a project idea .
* @param employeeName the employee
* @param projectIdeaTitle from which we get the match history
* @param status the status
* @return String the confirmation message
* This method is used to return a match message that the employee was matched or suggested to supervise the project idea .
* @param employeeName the name of the employee
* @param projectIdeaTitle the title of the project idea
* @param status the status of the match
* @return String the match message
*/
private String createMatchMessage(final String employeeName, final String projectIdeaTitle, Match.Status status) {
StringBuilder messageStr = new StringBuilder();
@ -265,10 +270,10 @@ public class ManualMatchPanel extends Panel {
/**
*
* This method is used to return a decline message if an employee already has declined a Match between the employee and a specific project idea .
* This method is used to return a decline message if an employee already has declined to supervise the project idea .
* @param supervisor the employee
* @param projectIdea from which we get the match history
* @param status the status
* @param projectIdea the project idea (from which we get the match history)
* @param status the status of the match
* @return String the decline message
*/
private String createDeclineMessage(User supervisor, ProjectIdea projectIdea, Match.Status status) {
@ -294,10 +299,10 @@ public class ManualMatchPanel extends Panel {
/**
*
* This method is used to return a confirmation message that you want to create a match between the employee and a specific project idea .
* This method is used to return a confirmation message (is shown in a confirmation dialog) for a match between the employee and the project idea .
* @param supervisor the employee
* @param status the status
* @return String the decline message
* @param status the status of the match
* @return String the confirmation message
*/
private String createConfirmationMessage(User supervisor, Match.Status status) {
StringBuilder stringBuilder = new StringBuilder();

@ -64,7 +64,7 @@ public class ManualSetReviewerPanel extends Panel {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
if(testACInputString(autocompleteReviewerField) ) {
Session.get().error("No reviewer could be selected because the data was invalid.");
Session.get().error("No reviewer could be selected because the input was invalid.");
target.addComponent(localFeedback);
} else {
ProjectIdea projectIdea = projectIdeaModel.getObject();
@ -83,6 +83,11 @@ public class ManualSetReviewerPanel extends Panel {
setResponsePage(AdminManageProjectIdeaPage.class);
target.addComponent(feedbackPanel); // is only activated on "this"
}
@Override
protected boolean isDisplayConfirmation() {
return saveButton.getMessageContentHTML() != null && !saveButton.getMessageContentHTML().isEmpty();
}
};
}
@ -114,7 +119,7 @@ public class ManualSetReviewerPanel extends Panel {
//noinspection unchecked
autoCompleteObjectField.setModelObject(null);
autoCompleteObjectField.clearInput();
saveButton.setMessageContentHTML("No supervisor was selected.");
saveButton.setMessageContentHTML(null);
target.addComponent(currentFragment);
target.addComponent(autoCompleteObjectField);
target.addComponent(saveButton);
@ -199,18 +204,34 @@ public class ManualSetReviewerPanel extends Panel {
}
};
}
private String getConfirmMessage(String employeeName, String projectIdeaTitle) {
/**
*
* This method is used to return an confirmation message (is shown in a confirmation dialog)
* to the administrator, that the employee really should be suggested as a reviewer for the project idea.
* @param projectIdeaTitle the title of the project idea
* @param reviewerName the name of the suggested reviewer
* @return String the confirmation message
*/
private String getConfirmMessage(final String projectIdeaTitle, final String reviewerName) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Are you sure that you want to suggest ");
stringBuilder.append(employeeName);
stringBuilder.append(reviewerName);
stringBuilder.append(" as reviewer for the project idea ");
stringBuilder.append(projectIdeaTitle);
stringBuilder.append("?");
return stringBuilder.toString();
}
private String getInfoMessage(String projectIdeaTitle, String reviewerName) {
/**
*
* This method is used to return an information message that the employee was suggested as a reviewer for the project idea.
* @param projectIdeaTitle the title of the project idea
* @param reviewerName the name of the suggested reviewer
* @return String the information message
*/
private String getInfoMessage(final String projectIdeaTitle, final String reviewerName) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(reviewerName);
stringBuilder.append(" was suggested reviewer for the project idea ");
@ -219,6 +240,13 @@ public class ManualSetReviewerPanel extends Panel {
return stringBuilder.toString();
}
/**
*
* This method is used to return an error message which is shown in case of an unforeseen error.
* @param projectIdeaTitle the title of the project idea
* @param reviewerName the name of the presumed reviewer
* @return String the error message
*/
private String getErrorMessage(String projectIdeaTitle, String reviewerName) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("An error occurred when suggesting ");