List of usage examples for org.apache.wicket.markup.html.form FormComponent getConvertedInput
public final T getConvertedInput()
From source file:com.userweave.components.validator.ValidationStyleBehavior.java
License:Open Source License
@Override public void onComponentTag(final Component component, final ComponentTag tag) { FormComponent comp = (FormComponent) component; if (comp.isValid() && comp.getConvertedInput() != null) { tag.getAttributes().put("class", "input-text"); } else if (!comp.isValid()) { tag.getAttributes().put("class", "input-text-invalid"); }/*from w ww. j ava 2 s . co m*/ }
From source file:net.databinder.auth.valid.EqualPasswordConvertedInputValidator.java
License:Open Source License
@Override public void validate(Form form) { FormComponent[] components = getDependentFormComponents(); final FormComponent formComponent1 = components[0]; final FormComponent formComponent2 = components[1]; if (!Objects.equal(formComponent1.getConvertedInput(), formComponent2.getConvertedInput())) error(formComponent2);/* w w w. j av a2s. c o m*/ }
From source file:org.cast.cwm.data.validator.DuplicateInputValidator.java
License:Open Source License
@Override public void validate(Form<?> form) { int in = 0;//from w w w . ja v a 2 s. c o m List<FormComponent<?>> inputs = new ArrayList<FormComponent<?>>(); for (FormComponent<?> c : components) { if (c.getConvertedInput() != null) { in++; inputs.add(c); } } // Error if we've gone over the limit for duplication if (in > count) { for (FormComponent<?> c : inputs) error(c, "DuplicateInputValidator.count"); } // Error if we don't have enough duplication if (in < required) { for (FormComponent<?> c : components) error(c, required == count ? "DuplicateInputValidator.exact" : "DuplicateInputValidator.required"); } }
From source file:org.geoserver.web.data.store.StoreNameValidator.java
License:Open Source License
/** * Performs the cross validation between the selected workspace and the assigned store name * <p>/*from w w w. j av a 2s . c o m*/ * If there's already a {@link StoreInfo} in the selected workspace with the same name than the * choosed one the store name form component is set with a proper {@link IValidationError error * message} * </p> * * @see IFormValidator#validate(Form) */ public void validate(final Form form) { final FormComponent[] components = getDependentFormComponents(); final FormComponent wsComponent = components[0]; final FormComponent nameComponent = components[1]; WorkspaceInfo workspace = (WorkspaceInfo) wsComponent.getConvertedInput(); String name = (String) nameComponent.getConvertedInput(); if (name == null) { if (required) { ValidationError error = new ValidationError(); error.addMessageKey("StoreNameValidator.storeNameRequired"); nameComponent.error((IValidationError) error); } return; } Catalog catalog = GeoServerApplication.get().getCatalog(); final StoreInfo existing = catalog.getStoreByName(workspace, name, StoreInfo.class); if (existing != null) { final String existingId = existing.getId(); if (!existingId.equals(edittingStoreId)) { ValidationError error = new ValidationError(); error.addMessageKey("StoreNameValidator.storeExistsInWorkspace"); error.setVariable("workspace", workspace.getName()); error.setVariable("storeName", name); nameComponent.error((IValidationError) error); } } }
From source file:org.webical.web.component.behavior.FormComponentValidationStyleBehavior.java
License:Open Source License
/** * Alter the class attribute of the component *///www.j av a2 s. co m @Override public void onComponentTag(final Component component, final ComponentTag tag) { // Only alter the style for form components if (component instanceof FormComponent) { FormComponent comp = (FormComponent) component; IValueMap attribs = tag.getAttributes(); String tagClass = ""; if (attribs.containsKey("class")) { tagClass = (String) attribs.get("class"); } if (comp.isValid() && comp.getConvertedInput() != null) { // The component is valid // Remove the invalid class tagClass.replace(CLASS_SEPERATOR + invalidClassName, ""); // add the valid class tagClass += CLASS_SEPERATOR + validClassName; tag.getAttributes().put("class", tagClass); } else if (!comp.isValid()) { // The component is invalid // Remove the valid class tagClass.replace(CLASS_SEPERATOR + validClassName, ""); // Add the invalid class tagClass += CLASS_SEPERATOR + invalidClassName; tag.getAttributes().put("class", tagClass); } } }
From source file:org.wickedsource.wickedforms.wicket6.validators.WickedFormValidator.java
License:Apache License
private void updateFormComponents() { formComponents = new ArrayList<FormComponent<?>>(); form.visitFormComponents(new IVisitor<FormComponent<?>, Void>() { @Override//w w w . j av a2s. co m public void component(FormComponent<?> component, IVisit<Void> visit) { String id = component.getMetaData(AbstractFormElementPanel.COMPONENT_ID_KEY); AbstractInputFieldModel inputFieldModel = getFieldModelWithId(id); if (inputFieldModel != null) { formComponents.add(component); inputFieldModel.setUserInput(component.getConvertedInput()); } } }); }