use of org.apache.wicket.validation.IValidatable 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.IValidatable 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.IValidatable 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).get();
target.add(getPageBase().getFeedbackPanel());
}
}
};
}
use of org.apache.wicket.validation.IValidatable 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.IValidatable in project openmeetings by apache.
the class ConfigForm method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
add(new DropDownChoice<>("type", Arrays.asList(Type.values()), new IChoiceRenderer<Type>() {
private static final long serialVersionUID = 1L;
@Override
public String getIdValue(Type rt, int index) {
return rt.name();
}
@Override
public Object getDisplayValue(Type rt) {
return rt.name();
}
@Override
public Type getObject(String id, IModel<? extends List<? extends Type>> choices) {
for (Type rt : choices.getObject()) {
if (rt.name().equals(id)) {
return rt;
}
}
return null;
}
}).setLabel(Model.of(getString("45"))).add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
update(target);
}
}));
add(new RequiredTextField<String>("key").setLabel(Model.of(getString("265"))).add(new IValidator<String>() {
private static final long serialVersionUID = 1L;
@Override
public void validate(IValidatable<String> validatable) {
Configuration c = cfgDao.forceGet(validatable.getValue());
if (c != null && !c.isDeleted() && !c.getId().equals(ConfigForm.this.getModelObject().getId())) {
validatable.error(new ValidationError(getString("error.cfg.exist")));
}
}
}));
add(valueS.setLabel(Model.of(getString("271"))).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
add(valueN.setLabel(Model.of(getString("271"))).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
add(valueB.setLabel(Model.of(getString("271"))).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
}
Aggregations