/** * Adds "aria-invalid" if the component is invalid. * * @param context the {@link FacesContext} * @param component the {@link UIInput} component to add attributes for * @throws IOException if any error occurs writing the response */ protected void renderARIAInvalid(FacesContext context, UIInput component) throws IOException { if (!component.isValid()) { ResponseWriter writer = context.getResponseWriter(); writer.writeAttribute(HTML.ARIA_INVALID, "true", null); } }
if (!startDateComponent.isValid()) { return; // Already invalidated. Don't care about it then.
if (!input.isValid()) { styleClass.append(" ui-state-error");
protected boolean isComponentValid(UIComponent comp) { if(comp instanceof UIInput) return ((UIInput)comp).isValid(); return true; }
protected String getStateStyleClasses(UIInput component) { String styleClases = ""; if (component.isRequired()) { styleClases += " ui-state-required"; } else { styleClases += " ui-state-optional"; } if (!component.isValid()) { styleClases += " ui-state-error"; } return styleClases; }
protected void renderResponseIfNotValid(FacesContext context) { if (!isValid()) { context.renderResponse(); } }
protected String getStateStyleClasses(UIInput component) { String styleClases = ""; if (component.isRequired()) { styleClases += " ui-state-required"; } else { styleClases += " ui-state-optional"; } if (!component.isValid()) { styleClases += " ui-state-error"; } return styleClases; }
@Override public boolean isValid() { return getWrapped().isValid(); }
/** * <p>Return the submittedValue value of this {@link UIInput} component. * This method should only be used by the <code>decode()</code> and * <code>validate()</code> method of this component, or * its corresponding {@link Renderer}.</p> */ @Override public Object getSubmittedValue() { if (submittedValue == null && !isValid() && considerEmptyStringNull(FacesContext.getCurrentInstance())) { // JAVASERVERFACES_SPEC_PUBLIC-671 return ""; } else { return submittedValue; } }
/** * <p>Return the submittedValue value of this {@link UIInput} component. * This method should only be used by the <code>decode()</code> and * <code>validate()</code> method of this component, or * its corresponding {@link Renderer}.</p> */ @Override public Object getSubmittedValue() { if (submittedValue == null && !isValid() && considerEmptyStringNull(FacesContext.getCurrentInstance())) { // JAVASERVERFACES_SPEC_PUBLIC-671 return ""; } else { return submittedValue; } }
@Override public boolean isValid() { return getWrapped().isValid(); }
/** * <p>Return the submittedValue value of this {@link UIInput} component. * This method should only be used by the <code>decode()</code> and * <code>validate()</code> method of this component, or * its corresponding {@link Renderer}.</p> */ @Override public Object getSubmittedValue() { if (submittedValue == null && !isValid() && considerEmptyStringNull(FacesContext.getCurrentInstance())) { // JAVASERVERFACES_SPEC_PUBLIC-671 return ""; } else { return submittedValue; } }
/** * <p>Return the submittedValue value of this {@link UIInput} component. * This method should only be used by the <code>decode()</code> and * <code>validate()</code> method of this component, or * its corresponding {@link Renderer}.</p> */ @Override public Object getSubmittedValue() { if (submittedValue == null && !isValid() && considerEmptyStringNull(FacesContext.getCurrentInstance())) { // JAVASERVERFACES_SPEC_PUBLIC-671 return ""; } else { return submittedValue; } }
public static boolean isError(final UIInput uiInput) { final FacesContext facesContext = FacesContext.getCurrentInstance(); return !uiInput.isValid() || facesContext.getMessages(uiInput.getClientId(facesContext)).hasNext(); }
public void processEvent(SystemEvent event) throws AbortProcessingException { FacesContext context = FacesContext.getCurrentInstance(); UIInput source = (UIInput) event.getSource(); Map<Object, Object> attributes = context.getAttributes(); if (!attributes.containsKey(DetectInvalidChild.class.getName()) && !source.isValid() && source.isRendered()) { attributes.put(DetectInvalidChild.class.getName(), source); } }
@Override public VisitResult visit(VisitContext context, UIComponent target) { // Yes, this check does look a bit strange, but really physically the very same single UIInput component is // been reused in all rows of the UIData component. It's only its internal state which changes on a per-row // basis, as would happen during the tree visit. Those changes are reflected in the "input" reference. if (target == input && rowIndex != table.getRowIndex() && input.isValid() && value.equals(input.getLocalValue())) { duplicate = true; duplicateIndex = table.getRowIndex(); return VisitResult.COMPLETE; } return VisitResult.ACCEPT; }
public boolean isValid() { setupPerspective(); boolean retValue=innerGetDelegateInput().isValid(); teardownPerspective(); return retValue; }
public static FacesMessage.Severity getMaximumSeverity(final UIComponent component) { final FacesContext facesContext = FacesContext.getCurrentInstance(); final List<FacesMessage> messages = facesContext.getMessageList(component.getClientId(facesContext)); final FacesMessage.Severity maximumSeverity = getMaximumSeverity(messages); final boolean invalid = component instanceof UIInput && !((UIInput) component).isValid(); return invalid && (maximumSeverity == null || FacesMessage.SEVERITY_ERROR.getOrdinal() > maximumSeverity.getOrdinal()) ? FacesMessage.SEVERITY_ERROR : maximumSeverity; }
/** * Executes validation logic. */ private void executeValidate(FacesContext context) { try { validate(context); } catch (RuntimeException e) { context.renderResponse(); throw e; } if (!isValid()) { context.validationFailed(); context.renderResponse(); } }
protected void validateValue(FacesContext context, Object newValue) { if (isValid() && isRequired() && UIInputUtil.isEmpty(newValue)) { Object[] args = new Object[] { UIComponentUtil.getLabel(this) }; FacesMessageUtil.addErrorComponentMessage(context, this, REQUIRED_MESSAGE_ID, args); setValid(false); } if (isValid() && !UIInputUtil.isEmpty(newValue)) { validateFromAddedValidator(context, newValue); validateFromBinding(context, newValue); } validateForExtension(context, newValue); }