Skip to content

Commit

Permalink
2592: fix validation errors on add/edit form not displaying (sakaipro…
Browse files Browse the repository at this point in the history
  • Loading branch information
payten authored and steveswinsburg committed Jul 13, 2016
1 parent 8728b11 commit 4607b2f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ label.addgradeitem.release = Release item to students?
label.addgradeitem.include = Include item in course grade calculations?
label.addgradeitem.nocategories = Categories have not been configured.
label.addgradeitem.categorywithweight = {0} ({1})
error.addgradeitem.points = Points required and must be greater than zero.
error.addgradeitem.points = Points required and must be a number greater than zero.
error.addgradeitem.title = Title required and must be unique.
error.addgradeitem.exception = Error creating Assignment.
notification.addgradeitem.success = Gradebook item ''{0}'' has been created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.apache.wicket.ajax.attributes.AjaxCallListener;
import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.markup.html.form.Form;

/**
* A GradebookNG implementation of Wicket's AjaxButton that
Expand All @@ -15,6 +16,10 @@ public GbAjaxButton(String id) {
super(id);
}

public GbAjaxButton(String id, Form<?> form) {
super(id, form);
}

@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public AddOrEditGradeItemPanel(final String id, final ModalWindow window, final
// form
final Form<Assignment> form = new Form<Assignment>("addOrEditGradeItemForm", formModel);

final GbAjaxButton submit = new GbAjaxButton("submit") {
final GbAjaxButton submit = new GbAjaxButton("submit", form) {
private static final long serialVersionUID = 1L;

@Override
Expand Down Expand Up @@ -166,7 +166,11 @@ public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
}
}
}
}

@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.addChildren(form, FeedbackPanel.class);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.apache.wicket.util.convert.ConversionException;
import org.apache.wicket.validation.IValidatable;
import org.apache.wicket.validation.IValidationError;
import org.apache.wicket.validation.IValidator;
import org.sakaiproject.gradebookng.business.GbCategoryType;
import org.sakaiproject.gradebookng.business.GbGradingType;
import org.sakaiproject.gradebookng.business.GradebookNgBusinessService;
Expand Down Expand Up @@ -70,6 +74,17 @@ public AddOrEditGradeItemPanelContent(final String id, final Model<Assignment> a
public boolean isEnabled() {
return !assignment.isExternallyMaintained();
}

@Override
public boolean isRequired() {
return true;
}

@Override
public void error(IValidationError error) {
// Use our fancy error message for all validation errors
error(getString("error.addgradeitem.title"));
}
};
add(title);

Expand All @@ -89,6 +104,17 @@ public boolean isEnabled() {
public boolean isEnabled() {
return !assignment.isExternallyMaintained();
}

@Override
public boolean isRequired() {
return true;
}

@Override
public void error(IValidationError error) {
// Use our fancy error message for all validation errors
error(getString("error.addgradeitem.points"));
}
};
add(points);

Expand Down

0 comments on commit 4607b2f

Please sign in to comment.