use of org.apache.wicket.validation.IValidator in project midpoint by Evolveum.
the class WizardStep method createObjectClassValidator.
protected IValidator<String> createObjectClassValidator(final IModel<List<QName>> model) {
return new IValidator<String>() {
@Override
public void validate(IValidatable<String> validated) {
String value = validated.getValue();
List<QName> list = model.getObject();
List<String> stringList = new ArrayList<>();
for (QName q : list) {
stringList.add(q.getLocalPart());
}
if (!stringList.contains(value)) {
error(createStringResource("SchemaHandlingStep.message.validationError", value).getString());
AjaxRequestTarget target = getRequestCycle().find(AjaxRequestTarget.class);
target.add(getPageBase().getFeedbackPanel());
}
}
};
}
use of org.apache.wicket.validation.IValidator in project midpoint by Evolveum.
the class PageReport method createFullXmlValidator.
private IValidator<String> createFullXmlValidator() {
return new IValidator<String>() {
@Override
public void validate(IValidatable<String> validatable) {
String value = validatable.getValue();
OperationResult result = new OperationResult(OPERATION_VALIDATE_REPORT);
Holder<PrismObject<ReportType>> reportHolder = new Holder<>(null);
OpResult opResult = null;
try {
validateObject(value, reportHolder, PrismContext.LANG_XML, true, result);
if (!result.isAcceptable()) {
result.recordFatalError("Could not validate object", result.getCause());
opResult = OpResult.getOpResult((PageBase) getPage(), result);
validatable.error(new RawValidationError(opResult));
}
} catch (Exception e) {
LOGGER.error("Validation problem occured." + e.getMessage());
result.recordFatalError("Could not validate object.", e);
try {
opResult = OpResult.getOpResult((PageBase) getPage(), result);
validatable.error(new RawValidationError(opResult));
} catch (Exception ex) {
error(ex);
}
}
}
};
}
use of org.apache.wicket.validation.IValidator in project midpoint by Evolveum.
the class PageAccounts method createObjectClassValidator.
private IValidator<String> createObjectClassValidator() {
return new IValidator<String>() {
@Override
public void validate(IValidatable<String> validatable) {
String value = validatable.getValue();
AccountDetailsSearchDto dto = searchModel.getObject();
List<QName> accountObjectClassList = dto.getObjectClassList();
List<String> accountObjectClassListString = new ArrayList<>();
for (QName objectClass : accountObjectClassList) {
accountObjectClassListString.add(objectClass.getLocalPart());
}
if (!accountObjectClassListString.contains(value)) {
error(createStringResource("PageAccounts.message.validationError", value).getString());
}
}
};
}
use of org.apache.wicket.validation.IValidator 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;
}
Aggregations