Coverage Report - javax.faces.component.html.HtmlInputHidden
 
Classes in this File Line Coverage Branch Coverage Complexity
HtmlInputHidden
63%
19/30
50%
5/10
4.333
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package javax.faces.component.html;
 17  
 
 18  
 import javax.faces.component.UIInput;
 19  
 import javax.faces.context.FacesContext;
 20  
 import javax.faces.el.ValueBinding;
 21  
 import javax.faces.internal.FacesMessageUtil;
 22  
 
 23  
 import org.seasar.framework.util.AssertionUtil;
 24  
 
 25  
 /**
 26  
  * @author shot
 27  
  * @author higa
 28  
  */
 29  
 public class HtmlInputHidden extends UIInput {
 30  
 
 31  
     public static final String COMPONENT_TYPE = "javax.faces.HtmlInputHidden";
 32  
 
 33  
     private static final String DEFAULT_RENDERER_TYPE = "javax.faces.Hidden";
 34  
 
 35  131
     public HtmlInputHidden() {
 36  131
         setRendererType(DEFAULT_RENDERER_TYPE);
 37  131
     }
 38  
 
 39  
     public void processValidators(FacesContext context) {
 40  2
         AssertionUtil.assertNotNull("context", context);
 41  1
         if (!isRendered()) {
 42  0
             return;
 43  
         }
 44  1
         super.processValidators(context);
 45  1
         if (!isImmediate()) {
 46  1
             executeValidate(context);
 47  
         }
 48  
         try {
 49  1
             updateModelImmediately(context);
 50  0
         } catch (RuntimeException e) {
 51  0
             context.renderResponse();
 52  0
             throw e;
 53  1
         }
 54  1
     }
 55  
 
 56  
     protected void updateModelImmediately(FacesContext context) {
 57  1
         AssertionUtil.assertNotNull("context", context);
 58  1
         if (!isValid() || !isLocalValueSet()) {
 59  0
             return;
 60  
         }
 61  1
         final ValueBinding valueBinding = getValueBinding("value");
 62  1
         if (valueBinding == null) {
 63  0
             return;
 64  
         }
 65  
         try {
 66  1
             Object localValue = getLocalValue();
 67  1
             valueBinding.setValue(context, localValue);
 68  0
         } catch (RuntimeException e) {
 69  0
             Object[] args = { getId() };
 70  0
             context.getExternalContext().log(e.getMessage(), e);
 71  0
             FacesMessageUtil.addErrorComponentMessage(context, this,
 72  
                     CONVERSION_MESSAGE_ID, args);
 73  0
             setValid(false);
 74  1
         }
 75  1
     }
 76  
 }