Java Code Examples for org.apache.wicket.markup.html.form.FormComponent#isValid()
The following examples show how to use
org.apache.wicket.markup.html.form.FormComponent#isValid() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValidationMsgBehavior.java From wicket-spring-boot with Apache License 2.0 | 6 votes |
@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); } }
Example 2
Source File: ValidationMessageBehavior.java From nextreports-server with Apache License 2.0 | 6 votes |
@Override public void afterRender(Component component) { super.afterRender(component); FormComponent<?> fc = null; if (component instanceof Palette) { fc = ((Palette<?>) component).getRecorderComponent(); } else if (component instanceof FormComponent) { fc = (FormComponent<?>) component; } if ((fc != null) && !fc.isValid() ) { String error; if (fc.hasFeedbackMessage()) { error = fc.getFeedbackMessages().first().getMessage().toString(); } else { error = "Your input is invalid."; } component.getResponse().write("<div class=\"validationMessage\">" + error + "</div>"); } }
Example 3
Source File: ValidationMsgBehavior.java From wicket-spring-boot with Apache License 2.0 | 5 votes |
@Override public void beforeRender(Component c) { if (c instanceof FormComponent) { FormComponent fc = (FormComponent) c; if (!fc.isValid()) { super.beforeRender(c); } } }
Example 4
Source File: ComponentVisualErrorBehaviour.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Changes the CSS class of the linked {@link FormComponent} via AJAX. * * @param ajaxRequestTarget of type AjaxRequestTarget * @param valid Was the validation succesful? * @param cssClass The CSS class that must be set on the linked {@link FormComponent} */ private void changeCssClass(AjaxRequestTarget ajaxRequestTarget, boolean valid, String cssClass) { FormComponent formComponent = getFormComponent(); if(formComponent.isValid() == valid){ formComponent.add(new AttributeModifier("class", true, new Model("formInputField " + cssClass))); ajaxRequestTarget.add(formComponent); } if(updateComponent!=null){ ajaxRequestTarget.add(updateComponent); } }
Example 5
Source File: ComponentVisualErrorBehaviour.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Changes the CSS class of the linked {@link FormComponent} via AJAX. * * @param ajaxRequestTarget of type AjaxRequestTarget * @param valid Was the validation succesful? * @param cssClass The CSS class that must be set on the linked {@link FormComponent} */ private void changeCssClass(AjaxRequestTarget ajaxRequestTarget, boolean valid, String cssClass) { FormComponent formComponent = getFormComponent(); if(formComponent.isValid() == valid){ formComponent.add(new AttributeModifier("class", true, new Model("formInputField " + cssClass))); ajaxRequestTarget.add(formComponent); } if(updateComponent!=null){ ajaxRequestTarget.add(updateComponent); } }
Example 6
Source File: AbstractFieldsetPanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
/** * 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; }
Example 7
Source File: ErrorHighlightBehavior.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
@Override public void onComponentTag(final Component component, final ComponentTag tag) { if (component instanceof FormComponent< ? >) { final FormComponent< ? > fc = (FormComponent< ? >) component; if (fc instanceof AbstractSelectPanel< ? > == true) { // Do ignore the AbstractSelectPanels, otherwise the icons looks not very pretty on colored background. return; } if (fc.isValid() == true) { return; } } else if (component.getParent() != null && component.getParent() instanceof FieldsetPanel) { final FieldsetPanel fs = (FieldsetPanel) component.getParent(); if (fs.isValid() == true) { return; } } else { return; } final String value = tag.getAttribute("class"); if (StringUtils.isEmpty(value) == true) { tag.put("class", "has-error"); } else { tag.put("class", value + " has-error"); } }