Search in sources :

Example 6 with ValidationError

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);
    }
}
Also used : ValidationError(org.apache.wicket.validation.ValidationError)

Example 7 with ValidationError

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;
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) IValidator(org.apache.wicket.validation.IValidator) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel) ValidationError(org.apache.wicket.validation.ValidationError) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) IValidatable(org.apache.wicket.validation.IValidatable)

Example 8 with ValidationError

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);
    }
}
Also used : ValidationError(org.apache.wicket.validation.ValidationError) StringResourceModel(org.apache.wicket.model.StringResourceModel) Date(java.util.Date)

Example 9 with ValidationError

use of org.apache.wicket.validation.ValidationError in project ocvn by devgateway.

the class YearValidator method validate.

@Override
public void validate(final IValidatable<Integer> validatable) {
    if (validatable.getValue() == null) {
        return;
    }
    if (maxCurrentYear && validatable.getValue() > Calendar.getInstance().get(Calendar.YEAR)) {
        ValidationError error = new ValidationError();
        error.addKey(this, "maxCurrentYear");
        validatable.error(error);
    }
}
Also used : ValidationError(org.apache.wicket.validation.ValidationError)

Aggregations

ValidationError (org.apache.wicket.validation.ValidationError)9 Date (java.util.Date)2 StringResourceModel (org.apache.wicket.model.StringResourceModel)2 TextPanel (com.evolveum.midpoint.web.component.input.TextPanel)1 LaddaAjaxButton (de.agilecoders.wicket.extensions.markup.html.bootstrap.ladda.LaddaAjaxButton)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)1 FormComponent (org.apache.wicket.markup.html.form.FormComponent)1 ResourceModel (org.apache.wicket.model.ResourceModel)1 IValidatable (org.apache.wicket.validation.IValidatable)1 IValidator (org.apache.wicket.validation.IValidator)1 EditingDisabledEvent (org.devgateway.toolkit.forms.wicket.events.EditingDisabledEvent)1