Coverage Report - org.seasar.teeda.core.render.html.HtmlInputTextareaRenderer
 
Classes in this File Line Coverage Branch Coverage Complexity
HtmlInputTextareaRenderer
100%
32/32
100%
2/2
1.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 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.HtmlInputTextarea;
 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  34
 public class HtmlInputTextareaRenderer extends AbstractInputRenderer {
 35  
 
 36  
     public static final String COMPONENT_FAMILY = "javax.faces.Input";
 37  
 
 38  
     public static final String RENDERER_TYPE = "javax.faces.Textarea";
 39  
 
 40  34
     private final IgnoreAttribute ignoreAttribute = new IgnoreAttribute();
 41  
     {
 42  34
         addIgnoreAttributeName(JsfConstants.ID_ATTR);
 43  34
         addIgnoreAttributeName(JsfConstants.VALUE_ATTR);
 44  34
         addIgnoreAttributeName(JsfConstants.NAME_ATTR);
 45  34
         addIgnoreAttributeName(JsfConstants.STYLE_CLASS_ATTR);
 46  34
     }
 47  
 
 48  
     public void encodeEnd(FacesContext context, UIComponent component)
 49  
             throws IOException {
 50  9
         assertNotNull(context, component);
 51  7
         if (!component.isRendered()) {
 52  1
             return;
 53  
         }
 54  6
         encodeHtmlInputTextareaEnd(context, (HtmlInputTextarea) component);
 55  6
     }
 56  
 
 57  
     protected void encodeHtmlInputTextareaEnd(FacesContext context,
 58  
             HtmlInputTextarea htmlInputTextarea) throws IOException {
 59  6
         ResponseWriter writer = context.getResponseWriter();
 60  6
         writer.startElement(JsfConstants.TEXTAREA_ELEM, htmlInputTextarea);
 61  6
         RendererUtil.renderIdAttributeIfNecessary(writer, htmlInputTextarea,
 62  
                 getIdForRender(context, htmlInputTextarea));
 63  6
         RendererUtil.renderAttribute(writer, JsfConstants.NAME_ATTR,
 64  
                 htmlInputTextarea.getClientId(context));
 65  6
         renderStyleClass(context, htmlInputTextarea, writer);
 66  6
         renderRemainAttributes(htmlInputTextarea, writer, ignoreAttribute);
 67  
 
 68  
         //render value at last.
 69  6
         String value = ValueHolderUtil.getValueForRender(context,
 70  
                 htmlInputTextarea);
 71  6
         writer.writeText(value, null);
 72  6
         writer.endElement(JsfConstants.TEXTAREA_ELEM);
 73  6
     }
 74  
 
 75  
     protected void renderStyleClass(final FacesContext context,
 76  
             final HtmlInputTextarea htmlInputTextarea,
 77  
             final ResponseWriter writer) throws IOException {
 78  6
         final String styleClass = htmlInputTextarea.getStyleClass();
 79  6
         RendererUtil.renderAttribute(writer, JsfConstants.STYLE_CLASS_ATTR,
 80  
                 styleClass);
 81  6
     }
 82  
 
 83  
     public void decode(FacesContext context, UIComponent component) {
 84  4
         assertNotNull(context, component);
 85  2
         decodeHtmlInputText(context, (HtmlInputTextarea) component);
 86  2
     }
 87  
 
 88  
     protected void decodeHtmlInputText(FacesContext context,
 89  
             HtmlInputTextarea htmlInputTextarea) {
 90  2
         getDecoder().decode(context, htmlInputTextarea);
 91  2
     }
 92  
 
 93  
     public void addIgnoreAttributeName(final String name) {
 94  136
         ignoreAttribute.addAttributeName(name);
 95  136
     }
 96  
 
 97  
 }