Coverage Report - org.seasar.teeda.core.render.html.HtmlInputHiddenRenderer
 
Classes in this File Line Coverage Branch Coverage Complexity
HtmlInputHiddenRenderer
100%
27/27
100%
2/2
1.5
 
 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 org.seasar.teeda.core.render.html;
 17  
 
 18  
 import java.io.IOException;
 19  
 
 20  
 import javax.faces.component.UIComponent;
 21  
 import javax.faces.component.html.HtmlInputHidden;
 22  
 import javax.faces.context.FacesContext;
 23  
 import javax.faces.context.ResponseWriter;
 24  
 import javax.faces.internal.IgnoreAttribute;
 25  
 
 26  
 import org.seasar.teeda.core.JsfConstants;
 27  
 import org.seasar.teeda.core.render.AbstractInputRenderer;
 28  
 import org.seasar.teeda.core.util.RendererUtil;
 29  
 import org.seasar.teeda.core.util.ValueHolderUtil;
 30  
 
 31  
 /**
 32  
  * @author manhole
 33  
  */
 34  33
 public class HtmlInputHiddenRenderer extends AbstractInputRenderer {
 35  
 
 36  
     public static final String COMPONENT_FAMILY = "javax.faces.Input";
 37  
 
 38  
     public static final String RENDERER_TYPE = "javax.faces.Hidden";
 39  
 
 40  33
     private final IgnoreAttribute ignoreComponent = new IgnoreAttribute();
 41  
     {
 42  33
         ignoreComponent.addAttributeName(JsfConstants.ID_ATTR);
 43  33
         ignoreComponent.addAttributeName(JsfConstants.VALUE_ATTR);
 44  33
         ignoreComponent.addAttributeName(JsfConstants.TYPE_ATTR);
 45  33
         ignoreComponent.addAttributeName(JsfConstants.NAME_ATTR);
 46  33
     }
 47  
 
 48  
     public void encodeEnd(FacesContext context, UIComponent component)
 49  
             throws IOException {
 50  8
         assertNotNull(context, component);
 51  6
         if (!component.isRendered()) {
 52  1
             return;
 53  
         }
 54  5
         encodeHtmlInputHiddenEnd(context, (HtmlInputHidden) component);
 55  5
     }
 56  
 
 57  
     protected void encodeHtmlInputHiddenEnd(FacesContext context,
 58  
             HtmlInputHidden htmlInputHidden) throws IOException {
 59  5
         ResponseWriter writer = context.getResponseWriter();
 60  5
         writer.startElement(JsfConstants.INPUT_ELEM, htmlInputHidden);
 61  5
         RendererUtil.renderAttribute(writer, JsfConstants.TYPE_ATTR,
 62  
                 JsfConstants.HIDDEN_VALUE);
 63  5
         RendererUtil.renderIdAttributeIfNecessary(writer, htmlInputHidden,
 64  
                 getIdForRender(context, htmlInputHidden));
 65  5
         RendererUtil.renderAttribute(writer, JsfConstants.NAME_ATTR,
 66  
                 htmlInputHidden.getClientId(context));
 67  
 
 68  5
         String value = ValueHolderUtil.getValueForRender(context,
 69  
                 htmlInputHidden);
 70  5
         RendererUtil.renderAttribute(writer, JsfConstants.VALUE_ATTR, value);
 71  5
         renderRemainAttributes(htmlInputHidden, writer, ignoreComponent);
 72  5
         writer.endElement(JsfConstants.INPUT_ELEM);
 73  5
     }
 74  
 
 75  
     public void decode(FacesContext context, UIComponent component) {
 76  4
         assertNotNull(context, component);
 77  2
         decodeHtmlInputHidden(context, (HtmlInputHidden) component);
 78  2
     }
 79  
 
 80  
     protected void decodeHtmlInputHidden(FacesContext context,
 81  
             HtmlInputHidden htmlInputHidden) {
 82  2
         getDecoder().decode(context, htmlInputHidden);
 83  2
     }
 84  
 
 85  
 }