use of org.apache.wicket.validation.ValidationError in project ocvn by devgateway.
the class EarlierThanDateValidator method validate.
@Override
public void validate(final IValidatable<Date> validatable) {
if (highDate == null) {
return;
}
if (validatable.getValue() != null && highDate.before(validatable.getValue())) {
ValidationError error = new ValidationError(this);
error.setVariable("highDate", highDate);
validatable.error(error);
}
}
use of org.apache.wicket.validation.ValidationError in project ocvn by devgateway.
the class VietnamImportPage method addImportButton.
protected void addImportButton() {
importButton = new LaddaAjaxButton("import", Type.Danger) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
send(getPage(), Broadcast.BREADTH, new EditingDisabledEvent());
logText.getSelfUpdatingBehavior().restart(target);
importContainer.setVisibilityAllowed(true);
target.add(importContainer);
target.add(form);
try {
vnExcelImportService.importAllSheets(importForm.getModelObject().getFileTypes(), importForm.getModelObject().getSourceFiles().getPrototypeDatabaseFile().isEmpty() ? null : importForm.getModelObject().getSourceFiles().getPrototypeDatabaseFile().iterator().next().getContent().getBytes(), importForm.getModelObject().getSourceFiles().getLocationsFile().isEmpty() ? null : importForm.getModelObject().getSourceFiles().getLocationsFile().iterator().next().getContent().getBytes(), importForm.getModelObject().getSourceFiles().getPublicInstitutionsSuppliersFile().isEmpty() ? null : importForm.getModelObject().getSourceFiles().getPublicInstitutionsSuppliersFile().iterator().next().getContent().getBytes(), importForm.getModelObject().getSourceFiles().getCityDepartmentGroupFile().isEmpty() ? null : importForm.getModelObject().getSourceFiles().getCityDepartmentGroupFile().iterator().next().getContent().getBytes(), importForm.getModelObject().getDropData(), importForm.getModelObject().getValidateData(), importForm.getModelObject().getFlagData());
} catch (Exception e) {
logger.error(e);
e.printStackTrace();
} finally {
target.add(logText);
target.add(feedbackPanel);
this.setEnabled(false);
target.add(this);
}
}
@Override
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
ValidationError error = new ValidationError();
error.addKey("formHasErrors");
error(error);
target.add(form);
target.add(feedbackPanel);
}
};
importButton.setLabel(new ResourceModel("startImportProcess"));
importButton.setIconType(FontAwesomeIconType.hourglass_start);
importForm.add(importButton);
}
use of org.apache.wicket.validation.ValidationError in project midpoint by Evolveum.
the class NotNullValidator method validate.
@Override
public void validate(IValidatable<T> validatable) {
if (validatable.getValue() == null) {
ValidationError err = new ValidationError();
err.addKey(key);
validatable.error(err);
}
}
use of org.apache.wicket.validation.ValidationError in project midpoint by Evolveum.
the class JasperReportConfigurationPanel method createTextPanel.
@SuppressWarnings({ "rawtypes", "unchecked" })
private <J> Component createTextPanel(String componentId, final IModel<J> model, String expression, final Boolean mandatory) {
TextPanel<String> textPanel = new TextPanel<String>(componentId, new PropertyModel<String>(model, expression));
FormComponent input = textPanel.getBaseFormComponent();
input.add(new AttributeAppender("style", "width: 100%"));
input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
input.add(new IValidator() {
private static final long serialVersionUID = 1L;
@Override
public void validate(IValidatable validatable) {
if (!mandatory) {
return;
}
if (validatable.getValue() == null) {
validatable.error(new ValidationError("JasperReportConfigurationPanel.errormsg"));
}
}
});
return textPanel;
}
use of org.apache.wicket.validation.ValidationError in project ocvn by devgateway.
the class EarlierThanDateFieldValidator method validate.
@Override
public void validate(final IValidatable<Date> validatable) {
highDate.getField().validate();
if (!highDate.getField().isValid()) {
return;
}
Date endDate = (Date) highDate.getField().getConvertedInput();
if (endDate != null && validatable.getValue() != null && endDate.before(validatable.getValue())) {
ValidationError error = new ValidationError(this);
error.setVariable("highDateName", new StringResourceModel(highDate.getLabelKey(), highDate.getParent(), null).getString());
validatable.error(error);
}
}
Aggregations