@Override public boolean isValid() { return component.isValid(); } };
public boolean isValid() { return component.isValid(); } };
public boolean isValid() { return FormComponent.this.isValid(); }
/** * Checks all child form components and calls {@link FormComponent#isValid()}. * * @return true if all childs are valid, otherwise false (if any child is invalid); */ public boolean isValid() { for (final FormComponent<?> formComponent : allFormComponents) { if (formComponent.isValid() == false) { return false; } } return true; }
@Override public void beforeRender(Component c) { if (c instanceof FormComponent) { FormComponent fc = (FormComponent) c; if (!fc.isValid()) { super.beforeRender(c); } } }
@Override public void applyState() { setComplete(nameComponent.getFormComponent().isValid()); } }
@Override public void applyState() { setComplete(nameComponent.getFormComponent().isValid()); } }
private boolean formComponentActive(FormComponent<?> formComponent) { return formComponent.isVisibleInHierarchy() && formComponent.isValid() && formComponent.isEnabled() && formComponent.isEnableAllowed(); } }
/** * Performs full validation of the form component, which consists of calling validateRequired(), * convertInput(), and validateValidators(). This method should only be used if the form * component needs to be fully validated outside the form process. */ public final void validate() { validateRequired(); if (isValid()) { convertInput(); if (isValid() && isRequired() && getConvertedInput() == null && isInputNullable()) { reportRequiredError(); } if (isValid()) { validateValidators(); } } }
/** Avoid borders around components and child components. */ private boolean hasInvalidParent(final Component component) { if (component == null) { return false; } if (component instanceof FieldsetPanel && ((FieldsetPanel) component).isValid() == false) { return true; } if (component instanceof FormComponent< ? > && ((FormComponent< ? >) component).isValid() == false) { return true; } return hasInvalidParent(component.getParent()); } }
public AutoLabelMarker(FormComponent<?> component) { setFlag(VALID, component.isValid()); setFlag(REQUIRED, component.isRequired()); setFlag(ENABLED, component.isEnabledInHierarchy()); }
public AutoLabelMarker(FormComponent<?> component) { setFlag(VALID, component.isValid()); setFlag(REQUIRED, component.isRequired()); setFlag(ENABLED, component.isEnabledInHierarchy()); }
@Override protected void onBeforeRender() { if (!formComponent.isValid()) { add(new AttributeModifier("class", Model.of("form-group has-error"))); } else { add(new AttributeModifier("class", "form-group")); } super.onBeforeRender(); }
@Override public void afterRender(Component component) { FormComponent fc = (FormComponent) component; if (!fc.isValid()) { String error; if (fc.hasFeedbackMessage()) { FeedbackMessage first = fc.getFeedbackMessages().first(); first.markRendered(); error = first.getMessage().toString(); } else { error = "Your input is invalid."; } fc.getResponse().write("*<span id=\"helpBlock2\" class=\"help-block\">"+error+"</span>"); super.afterRender(component); } }
@Override public void component(FormComponent<?> formComponent, IVisit<Void> visit) { if (formComponentActive(formComponent)) { formComponent.validate(); if (formComponent.isValid()) { if (!formComponent.processChildren()) { visit.dontGoDeeper(); } } else { error[0] = true; visit.dontGoDeeper(); } } visit.dontGoDeeper(); } });
public void updateFrom(FormComponent<?> component, AjaxRequestTarget target) { boolean valid = component.isValid(), required = component.isRequired(), enabled = component.isEnabledInHierarchy(); if (isValid() != valid) { target.appendJavaScript(String.format("Wicket.DOM.toggleClass('%s', '%s', %s);", getLabelIdFor(component), component.getString(CSS_ERROR_KEY, null, CSS_ERROR_DEFAULT), !valid)); } if (isRequired() != required) { target.appendJavaScript(String.format("Wicket.DOM.toggleClass('%s', '%s', %s);", getLabelIdFor(component), component.getString(CSS_REQUIRED_KEY, null, CSS_REQUIRED_DEFAULT), required)); } if (isEnabled() != enabled) { target.appendJavaScript(String.format("Wicket.DOM.toggleClass('%s', '%s', %s);", getLabelIdFor(component), component.getString(CSS_DISABLED_KEY, null, CSS_DISABLED_DEFAULT), !enabled)); } setFlag(VALID, valid); setFlag(REQUIRED, required); setFlag(ENABLED, enabled); }
@Override protected void onEvent(final AjaxRequestTarget target) { target.focusComponent(null); value.getField().inputChanged(); value.getField().validate(); if (value.getField().isValid()) { value.getField().valid(); value.getField().updateModel(); } }
@Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("for", component.getMarkupId()); if (component instanceof FormComponent) { FormComponent<?> fc = (FormComponent<?>)component; if (fc.isRequired()) { tag.append("class", component.getString(CSS_REQUIRED_KEY, null, CSS_REQUIRED_DEFAULT), " "); } if (!fc.isValid()) { tag.append("class", component.getString(CSS_ERROR_KEY, null, CSS_ERROR_DEFAULT), " "); } } if (!component.isEnabledInHierarchy()) { tag.append("class", component.getString(CSS_DISABLED_KEY, null, CSS_DISABLED_DEFAULT), " "); } }
@Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("for", component.getMarkupId()); if (component instanceof FormComponent) { FormComponent<?> fc = (FormComponent<?>)component; if (fc.isRequired()) { tag.append("class", component.getString(CSS_REQUIRED_KEY, null, CSS_REQUIRED_DEFAULT), " "); } if (!fc.isValid()) { tag.append("class", component.getString(CSS_ERROR_KEY, null, CSS_ERROR_DEFAULT), " "); } } if (!component.isEnabledInHierarchy()) { tag.append("class", component.getString(CSS_DISABLED_KEY, null, CSS_DISABLED_DEFAULT), " "); } }
@Override public void onClick(final AjaxRequestTarget target) { urlIsEditable = !urlIsEditable; urlComponent.modelChanging(); urlModel.setObject(getName()); urlComponent.modelChanged(); final Form<?> form = urlComponent.getForm(); if (form.hasFeedbackMessage()) { form.getFeedbackMessages().clear(); } if (!urlComponent.isValid()) { urlComponent.validate(); } target.add(this); target.add(urlComponent); target.focusComponent(urlIsEditable ? urlComponent : nameComponent); } };