/** * Create a {@link javax.faces.validator.Validator} based on the <code>binding</code> and/or * <code>validatorId</code> attributes as per the standard JSF <code><f:validator></code> implementation and * collect the render time attributes. Then create an anonymous <code>Validator</code> implementation which wraps * the created <code>Validator</code> and delegates the methods to it after setting the render time attributes only * and only if the <code>disabled</code> attribute evaluates <code>true</code> for the current request. Finally set * the anonymous implementation on the parent component. * @param context The involved facelet context. * @param parent The parent component to add the <code>Validator</code> to. * @throws IOException If something fails at I/O level. */ @Override public void apply(FaceletContext context, UIComponent parent) throws IOException { boolean insideCompositeComponent = UIComponent.getCompositeComponentParent(parent) != null; if (!ComponentHandler.isNew(parent) && !insideCompositeComponent) { // If it's not new nor inside a composite component, we're finished. return; } if (!(parent instanceof EditableValueHolder) || (insideCompositeComponent && getAttribute("for") == null)) { // It's inside a composite component and not reattached. TagHandlerDelegate will pickup it and pass the target component back if necessary. super.apply(context, parent); return; } addValidator(context, (EditableValueHolder) parent); }
/** * Create a {@link javax.faces.validator.Validator} based on the <code>binding</code> and/or * <code>validatorId</code> attributes as per the standard JSF <code><f:validator></code> implementation and * collect the render time attributes. Then create an anonymous <code>Validator</code> implementation which wraps * the created <code>Validator</code> and delegates the methods to it after setting the render time attributes only * and only if the <code>disabled</code> attribute evaluates <code>true</code> for the current request. Finally set * the anonymous implementation on the parent component. * @param context The involved facelet context. * @param parent The parent component to add the <code>Validator</code> to. * @throws IOException If something fails at I/O level. */ @Override public void apply(FaceletContext context, UIComponent parent) throws IOException { boolean insideCompositeComponent = UIComponent.getCompositeComponentParent(parent) != null; if (!ComponentHandler.isNew(parent) && !insideCompositeComponent) { // If it's not new nor inside a composite component, we're finished. return; } if (!(parent instanceof EditableValueHolder) || (insideCompositeComponent && getAttribute("for") == null)) { // It's inside a composite component and not reattached. TagHandlerDelegate will pickup it and pass the target component back if necessary. super.apply(context, parent); return; } addValidator(context, (EditableValueHolder) parent); }