List of usage examples for org.apache.wicket.markup.html.form FormComponent getValidators
@SuppressWarnings("unchecked") public final List<IValidator<? super T>> getValidators()
From source file:eu.uqasar.web.components.InputBeanValidationBorder.java
License:Apache License
/** * Checks if the component already has a PropertyValidator. * /*from ww w .ja va 2s. c om*/ * @param fc * @return */ private boolean hasPropertyValidator(FormComponent<T> fc) { for (IValidator<?> validator : fc.getValidators()) { if (validator instanceof PropertyValidator) { return true; } } return false; }
From source file:net.databinder.valid.hib.ValidDataForm.java
License:Open Source License
/** * Add a validator to any form components that have no existing validator * and whose model is recognized by {@link DatabinderValidator#addTo(FormComponent)}. *//*w w w . jav a 2 s .c o m*/ @Override protected void onBeforeRender() { super.onBeforeRender(); visitFormComponents(new FormComponent.AbstractVisitor() { @Override protected void onFormComponent(FormComponent formComponent) { if (formComponent.getValidators().isEmpty()) try { DatabinderValidator.addTo(formComponent); } catch (UnrecognizedModelException e) { } } }); }
From source file:net.ftlines.wicket.validation.bean.ValidationForm.java
License:Apache License
private boolean hasPropertyValidator(FormComponent<?> fc) { for (IValidator<?> validator : fc.getValidators()) { if (validator instanceof PropertyValidator) { return true; }/*w w w. ja v a2 s . c om*/ } return false; }
From source file:ontopoly.validators.ExternalValidation.java
License:Apache License
public static void validate(final FormComponent<String> component, final String value) { List<IValidator<String>> validators = component.getValidators(); final IValidatable<String> validatable = new IValidatable<String>() { public void error(IValidationError error) { component.error(error);//from w ww . ja va 2 s . c o m } public String getValue() { return value; } public boolean isValid() { return component.isValid(); } }; IValidator<String> validator = null; boolean isNull = value == null; try { Iterator<IValidator<String>> iter = validators.iterator(); while (iter.hasNext()) { validator = iter.next(); if (isNull == false || validator instanceof INullAcceptingValidator) validator.validate(validatable); if (!component.isValid()) break; } } catch (Exception e) { throw new WicketRuntimeException("Exception '" + e + "' occurred during validation " + validator.getClass().getName() + " on component " + component.getPath(), e); } }