use of org.jowidgets.validation.IValidationResult in project jo-client-platform by jo-source.
the class BeanSelectionDialogDefaults method initialize.
@Override
public void initialize(final IBeanSelectionDialogBluePrint<?> bluePrint) {
bluePrint.setContentScrolled(false);
bluePrint.setContentBorder();
bluePrint.setMissingInputHint("Bitte wählen Sie einen Datensatz aus");
bluePrint.setDefaultButtonPolicy(InputDialogDefaultButtonPolicy.DISABLED);
final IInputComponentValidationLabelBluePrint validationLabelBp = BPF.inputComponentValidationLabel();
validationLabelBp.setInitialValidationDecorator(new IDecorator<IValidationResult>() {
@Override
public IValidationResult decorate(final IValidationResult original) {
if (!original.isValid()) {
return original;
}
return null;
}
});
}
use of org.jowidgets.validation.IValidationResult in project jo-client-platform by jo-source.
the class BeansStateTrackerImpl method createValidationResult.
@Override
public IValidationResult createValidationResult() {
final IValidationResultBuilder builder = ValidationResult.builder();
for (final IBeanProxy<BEAN_TYPE> bean : new LinkedList<IBeanProxy<BEAN_TYPE>>(validationDirtyBeans)) {
final IValidationResult validationResult = bean.validate();
builder.addResult(validationResult);
if (validationResult.isOk()) {
validationDirtyBeans.remove(bean);
} else if (!validationResult.isValid()) {
break;
}
}
return builder.build();
}
use of org.jowidgets.validation.IValidationResult in project jo-client-platform by jo-source.
the class AttributesBeanPropertyValidator method validatePropertyImpl.
private IValidationResult validatePropertyImpl(final IBeanProxy<BEAN_TYPE> bean, final String propertyName) {
final IValidationResultBuilder builder = ValidationResult.builder();
final IValidator<Object> validator = validators.get(propertyName);
if (validator != null) {
final IValidationResult validationResult = validator.validate(bean.getValue(propertyName));
if (!validationResult.isValid()) {
return validationResult;
} else if (!validationResult.isOk()) {
builder.addResult(validationResult);
}
}
return builder.build();
}
use of org.jowidgets.validation.IValidationResult in project jo-client-platform by jo-source.
the class BeanProxyImpl method setValidationResults.
private void setValidationResults(final ValueHolder<IBeanValidationResult> firstWorstIndependendResultHolder, final Collection<IBeanValidationResult> results) {
if (results.size() > 0) {
boolean validationChanged = false;
// set the property dependent results
for (final IBeanValidationResult result : results) {
final String propertyName = result.getPropertyName();
final IValidationResult validationResult = result.getValidationResult();
final IValidationResult lastResult = validationResults.get(propertyName);
if (lastResult == null || !validationResult.getWorstFirst().equals(lastResult.getWorstFirst())) {
if (validationResult.isOk()) {
validationResults.remove(propertyName);
} else {
validationResults.put(propertyName, validationResult);
}
validationChanged = true;
}
}
// set the property independent result
final IValidationResult lastIndependentResult = independentWorstResult.get();
final IBeanValidationResult currentIndependentBeanValidationResult = firstWorstIndependendResultHolder.get();
if (currentIndependentBeanValidationResult != null) {
final IValidationResult currentIndependentResult = currentIndependentBeanValidationResult.getValidationResult();
if (lastIndependentResult == null || !currentIndependentResult.getWorstFirst().equals(lastIndependentResult.getWorstFirst())) {
independentWorstResult.set(currentIndependentResult);
validationChanged = true;
}
} else if (lastIndependentResult != null) {
independentWorstResult.set(null);
validationChanged = true;
}
if (validationChanged) {
fireValidationConditionsChanged();
}
}
}
use of org.jowidgets.validation.IValidationResult in project jo-client-platform by jo-source.
the class BeanProxyImplTest method testAllValidatorsForInitialValidPerson.
private void testAllValidatorsForInitialValidPerson(final IBeanProxy<IPerson> personProxy) {
IValidationResult validationResult = personProxy.validate();
Assert.assertTrue(validationResult.isOk());
// make name invalid
final IPerson person = personProxy.getBean();
person.setName(PersonNameValidator.FORBIDDEN_NAME);
validationResult = personProxy.validate();
IValidationMessage worstFirst = validationResult.getWorstFirst();
Assert.assertEquals(personAttributes.getAttribute(IPerson.NAME_PROPERTY).getCurrentLabel(), worstFirst.getContext());
Assert.assertEquals(MessageType.ERROR, worstFirst.getType());
// make name valid again
personProxy.undoModifications();
validationResult = personProxy.validate();
Assert.assertTrue(validationResult.isOk());
// make name invalid
person.setName(null);
validationResult = personProxy.validate();
worstFirst = validationResult.getWorstFirst();
Assert.assertEquals(personAttributes.getAttribute(IPerson.NAME_PROPERTY).getCurrentLabel(), worstFirst.getContext());
Assert.assertEquals(MessageType.INFO_ERROR, worstFirst.getType());
// make name valid again
personProxy.undoModifications();
validationResult = personProxy.validate();
Assert.assertTrue(validationResult.isOk());
// make lastname invalid
person.setLastname(null);
validationResult = personProxy.validate();
worstFirst = validationResult.getWorstFirst();
Assert.assertEquals(personAttributes.getAttribute(IPerson.LAST_NAME_PROPERTY).getCurrentLabel(), worstFirst.getContext());
Assert.assertEquals(MessageType.INFO_ERROR, worstFirst.getType());
// make lastname valid again
personProxy.undoModifications();
validationResult = personProxy.validate();
Assert.assertTrue(validationResult.isOk());
// make name invalid again
person.setName(PersonNameValidator.FORBIDDEN_NAME);
validationResult = personProxy.validate();
worstFirst = validationResult.getWorstFirst();
Assert.assertEquals(personAttributes.getAttribute(IPerson.NAME_PROPERTY).getCurrentLabel(), worstFirst.getContext());
Assert.assertEquals(MessageType.ERROR, worstFirst.getType());
// modify lastname valid
person.setLastname("Foo");
// name must still be invalid
validationResult = personProxy.validate();
worstFirst = validationResult.getWorstFirst();
Assert.assertEquals(personAttributes.getAttribute(IPerson.NAME_PROPERTY).getCurrentLabel(), worstFirst.getContext());
Assert.assertEquals(MessageType.ERROR, worstFirst.getType());
}
Aggregations