@Override protected MetaRuleset createMetaRuleset(Class type) { MetaRuleset ruleSet = super.createMetaRuleset(type); //Add rule to handle EL expressions ruleSet.addRule(_ValidatorRule.INSTANCE); return ruleSet; } }
bp.getRequestContext().put("schema-validation-enabled", "true"); bp.getRequestContext().put("jaxb-validation-event-handler", new ValidatorHandler());
/** * <p>Retrieve the id of the validator that is to be created and * added to the parent <code>EditableValueHolder</code>. All * subclasses should override this method because it is important * for Facelets to have a unique way of identifying the validators * that are added to this <code>EditableValueHolder</code> and * allows exclusions to work properly. An exclusion is a validator * declaration that has the attribute "disabled" which resolves to * false, instructing Facelets not to register a default validator * with the same id.</p> */ public String getValidatorId(FaceletContext ctx) { if (validatorId == null) { TagAttribute idAttr = getAttribute("validatorId"); if (idAttr == null) { return null; } else { return idAttr.getValue(ctx); } } return validatorId; }
public ValidatorInfo(FaceletContext ctx, ValidatorHandler owner) { this.owner = owner; this.ctx = ctx; this.validatorId = owner.getValidatorId(ctx); this.enabled = !owner.isDisabled(ctx); }
/** * Template method for creating a Validator instance * * @param ctx FaceletContext to use * @return a new Validator instance */ protected Validator createValidator(FaceletContext ctx) { if (_delegate.getValidatorId(ctx) == null) { throw new TagException(_delegate.getTag(), "Default behavior invoked of requiring " + "a validator-id passed in the constructor, must override ValidateHandler(ValidatorConfig)"); } return ctx.getFacesContext().getApplication().createValidator(_delegate.getValidatorId(ctx)); }
if (owner.isDisabled(ctx)) { Set<String> disabledIds = (Set<String>) RequestStateManager.get(context, RequestStateManager.DISABLED_VALIDATORS); disabledIds); disabledIds.add(owner.getValidatorId(ctx)); return; if (owner.getBinding() != null) { ve = owner.getBinding().getValueExpression(ctx, Validator.class); v = (Validator) ve.getValue(ctx); throw new TagException(owner.getTag(), "No Validator was created"); owner.setAttributes(ctx, v);
if (_delegate.isDisabled(faceletContext)) String validatorId = _delegate.getValidatorConfig().getValidatorId(); if (validatorId != null && !"".equals(validatorId)) ValueExpression ve = null; Validator v = null; if (_delegate.getBinding() != null) ve = _delegate.getBinding().getValueExpression(faceletContext, Validator.class); v = (Validator) ve.getValue(faceletContext); throw new TagException(_delegate.getTag(), "No Validator was created"); _delegate.setAttributes(faceletContext, v); evh.addValidator(v);
String validatorId = _delegate.getValidatorConfig().getValidatorId(); boolean disabled = _delegate.isDisabled(ctx); if (disabled) _delegate.getValidatorConfig().getNextHandler().apply(ctx, parent); if (validatorIdAvailable) _delegate.getValidatorConfig().getNextHandler().apply(ctx, parent); mctx.popEnclosingValidatorIdToStack(); if (groupsAvailable) throw new TagException(_delegate.getTag(), "is nested inside a composite component" + " but does not have a for attribute."); throw new TagException(_delegate.getTag(), "Parent not composite component or an instance of EditableValueHolder: " + parent);
public ValidatorTagHandlerDelegate(ValidatorHandler delegate) { _delegate = delegate; // According to jsf 2.0 spec section 10.4.1.4 // this tag can be used as a leave within an EditableValueHolder // or as a container to provide validator information for all // EditableValueHolder-children (and grandchildren and ...) // (this behavior is analog to <f:ajax>) // --> Determine if we have children: _wrapMode = FaceletsCompilerUtils.hasChildren(_delegate.getValidatorConfig()); _beanBeforeJsfValidation = null; }
@Override public void apply(FaceletContext ctx, UIComponent parent) throws IOException { ComponentSupport.copyPassthroughAttributes(ctx, parent, owner.getTag()); if (wrapping) { applyWrapping(ctx, parent); } else { applyNested(ctx, parent); } }
public String getValidationGroups(FaceletContext ctx) { TagAttribute attribute = _delegate.getTagAttribute("validationGroups"); if (attribute == null) { return null; } else { return attribute.getValue(ctx); } }
private void applyNested(FaceletContext ctx, UIComponent parent) { // only process if it's been created if (!ComponentHandler.isNew(parent)) { return; } if (parent instanceof EditableValueHolder) { applyAttachedObject(ctx.getFacesContext(), parent); } else if (UIComponent.isCompositeComponent(parent)) { if (null == owner.getFor()) { // PENDING(): I18N throw new TagException(owner.getTag(), "validator tags nested within composite components must have a non-null \"for\" attribute"); } // Allow the composite component to know about the target // component. CompositeComponentTagHandler.getAttachedObjectHandlers(parent).add(owner); } else { throw new TagException(owner.getTag(), "Parent not an instance of EditableValueHolder: " + parent); } }
String validatorId = _delegate.getValidatorConfig().getValidatorId(); _delegate.applyNextHandler(ctx, parent); throw new TagException(_delegate.getTag(), "is nested inside a composite component" + " but does not have a for attribute."); throw new TagException(_delegate.getTag(), "Parent not composite component or an instance of EditableValueHolder: " + parent);
public void applyAttributes(Validator v) { owner.setAttributes(ctx, v); }
if (owner.isDisabled(ctx)) { Set<String> disabledIds = (Set<String>) RequestStateManager.get(context, RequestStateManager.DISABLED_VALIDATORS); disabledIds); disabledIds.add(owner.getValidatorId(ctx)); return; if (owner.getBinding() != null) { ve = owner.getBinding().getValueExpression(ctx, Validator.class); v = (Validator) ve.getValue(ctx); throw new TagException(owner.getTag(), "No Validator was created"); owner.setAttributes(ctx, v);
if (_delegate.isDisabled(faceletContext)) String validatorId = _delegate.getValidatorConfig().getValidatorId(); if (validatorId != null && !"".equals(validatorId)) ValueExpression ve = null; Validator v = null; if (_delegate.getBinding() != null) ve = _delegate.getBinding().getValueExpression(faceletContext, Validator.class); v = (Validator) ve.getValue(faceletContext); throw new TagException(_delegate.getTag(), "No Validator was created"); _delegate.setAttributes(faceletContext, v); evh.addValidator(v);
/** * Template method for creating a Validator instance * * @param ctx FaceletContext to use * @return a new Validator instance */ protected Validator createValidator(FaceletContext ctx) { if (_delegate.getValidatorId(ctx) == null) { throw new TagException(_delegate.getTag(), "Default behavior invoked of requiring " + "a validator-id passed in the constructor, must override ValidateHandler(ValidatorConfig)"); } return ctx.getFacesContext().getApplication().createValidator(_delegate.getValidatorId(ctx)); }
String validatorId = _delegate.getValidatorConfig().getValidatorId(); boolean disabled = _delegate.isDisabled(ctx); if (disabled) _delegate.getValidatorConfig().getNextHandler().apply(ctx, parent); _delegate.getValidatorConfig().getNextHandler().apply(ctx, parent); throw new TagException(_delegate.getTag(), "is nested inside a composite component" + " but does not have a for attribute."); throw new TagException(_delegate.getTag(), "Parent not composite component or an instance of EditableValueHolder: " + parent);
public ValidatorTagHandlerDelegate(ValidatorHandler delegate) { _delegate = delegate; // According to jsf 2.0 spec section 10.4.1.4 // this tag can be used as a leave within an EditableValueHolder // or as a container to provide validator information for all // EditableValueHolder-children (and grandchildren and ...) // (this behavior is analog to <f:ajax>) // --> Determine if we have children: _wrapMode = FaceletsCompilerUtils.hasChildren(_delegate.getValidatorConfig()); }