Coverage Report - org.apache.myfaces.view.facelets.tag.jsf.core.ValidateDelegateHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidateDelegateHandler
0%
0/8
0%
0/2
1.5
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.myfaces.view.facelets.tag.jsf.core;
 20  
 
 21  
 import javax.faces.validator.Validator;
 22  
 import javax.faces.view.facelets.FaceletContext;
 23  
 import javax.faces.view.facelets.MetaRuleset;
 24  
 import javax.faces.view.facelets.TagAttribute;
 25  
 import javax.faces.view.facelets.ValidatorConfig;
 26  
 import javax.faces.view.facelets.ValidatorHandler;
 27  
 
 28  
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletAttribute;
 29  
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
 30  
 
 31  
 
 32  
 /**
 33  
  * Register a named Validator instance on the UIComponent associated with the closest parent UIComponent custom
 34  
  * action.<p/> See <a target="_new"
 35  
  * href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f/validator.html">tag documentation</a>.
 36  
  * 
 37  
  * @author Jacob Hookom
 38  
  * @version $Id$
 39  
  */
 40  
 @JSFFaceletTag(
 41  
         name = "f:validator",
 42  
         bodyContent = "empty", 
 43  
         tagClass="org.apache.myfaces.taglib.core.ValidatorImplTag")
 44  
 @JSFFaceletAttribute(name="disabled", deferredValueType="java.lang.Boolean", 
 45  
         desc="no description", longDescription="no description")
 46  
 public final class ValidateDelegateHandler extends ValidatorHandler
 47  
 {
 48  
 
 49  
     private final TagAttribute validatorId;
 50  
 
 51  
     public ValidateDelegateHandler(ValidatorConfig config)
 52  
     {
 53  0
         super(config);
 54  0
         this.validatorId = this.getAttribute("validatorId");
 55  0
     }
 56  
 
 57  
     /**
 58  
      * Uses the specified "validatorId" to get a new Validator instance from the Application.
 59  
      * 
 60  
      * @see javax.faces.application.Application#createValidator(java.lang.String)
 61  
      * @see javax.faces.view.facelets.ValidatorHandler#createValidator(javax.faces.view.facelets.FaceletContext)
 62  
      */
 63  
     protected Validator createValidator(FaceletContext ctx)
 64  
     {
 65  0
         return ctx.getFacesContext().getApplication().createValidator(this.getValidatorId(ctx));
 66  
     }
 67  
 
 68  
     protected MetaRuleset createMetaRuleset(Class type)
 69  
     {
 70  0
         return super.createMetaRuleset(type).ignoreAll();
 71  
     }
 72  
 
 73  
     @Override
 74  
     public String getValidatorId(FaceletContext ctx)
 75  
     {
 76  0
         if (validatorId == null)
 77  
         {
 78  0
             return null;
 79  
         }
 80  0
         return validatorId.getValue(ctx);
 81  
     }
 82  
 
 83  
 }