Coverage Report - org.apache.myfaces.shared_impl.renderkit.html.HtmlTextareaRendererBase
 
Classes in this File Line Coverage Branch Coverage Complexity
HtmlTextareaRendererBase
0%
0/24
0%
0/4
1.6
 
 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.shared_impl.renderkit.html;
 20  
 
 21  
 import org.apache.myfaces.shared_impl.renderkit.RendererUtils;
 22  
 import org.apache.myfaces.shared_impl.renderkit.html.HTML;
 23  
 import org.apache.myfaces.shared_impl.renderkit.html.HtmlRenderer;
 24  
 import org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils;
 25  
 
 26  
 import javax.faces.component.UIComponent;
 27  
 import javax.faces.component.UIInput;
 28  
 import javax.faces.component.UIOutput;
 29  
 import javax.faces.component.html.HtmlInputTextarea;
 30  
 import javax.faces.context.FacesContext;
 31  
 import javax.faces.context.ResponseWriter;
 32  
 import javax.faces.convert.ConverterException;
 33  
 import java.io.IOException;
 34  
 
 35  
 
 36  
 /**
 37  
  * @author Manfred Geiler (latest modification by $Author: matzew $)
 38  
  * @author Anton Koinov
 39  
  * @version $Revision: 557350 $ $Date: 2007-07-18 13:19:50 -0500 (Wed, 18 Jul 2007) $
 40  
  */
 41  0
 public class HtmlTextareaRendererBase
 42  
         extends HtmlRenderer
 43  
 {
 44  
     public void encodeEnd(FacesContext facesContext, UIComponent uiComponent)
 45  
             throws IOException
 46  
     {
 47  0
         RendererUtils.checkParamValidity(facesContext, uiComponent, UIInput.class);
 48  
 
 49  0
         encodeTextArea(facesContext, uiComponent);
 50  
 
 51  0
     }
 52  
 
 53  
     protected void encodeTextArea(FacesContext facesContext, UIComponent uiComponent) throws IOException {
 54  0
         ResponseWriter writer = facesContext.getResponseWriter();
 55  0
         writer.startElement(HTML.TEXTAREA_ELEM, uiComponent);
 56  
 
 57  0
         String clientId = uiComponent.getClientId(facesContext);
 58  0
         writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
 59  0
         HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
 60  
 
 61  0
         HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
 62  0
         if (isDisabled(facesContext, uiComponent))
 63  
         {
 64  0
             writer.writeAttribute(org.apache.myfaces.shared_impl.renderkit.html.HTML.DISABLED_ATTR, Boolean.TRUE, null);
 65  
         }
 66  
 
 67  0
         String strValue = org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(facesContext, uiComponent);
 68  0
         writer.writeText(strValue, org.apache.myfaces.shared_impl.renderkit.JSFAttr.VALUE_ATTR);
 69  
 
 70  0
         writer.endElement(HTML.TEXTAREA_ELEM);
 71  0
     }
 72  
 
 73  
     protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent)
 74  
     {
 75  
         //TODO: overwrite in extended HtmlTextareaRenderer and check for enabledOnUserRole
 76  0
         if (uiComponent instanceof HtmlInputTextarea)
 77  
         {
 78  0
             return ((HtmlInputTextarea)uiComponent).isDisabled();
 79  
         }
 80  
 
 81  0
         return org.apache.myfaces.shared_impl.renderkit.RendererUtils.getBooleanAttribute(uiComponent, HTML.DISABLED_ATTR, false);
 82  
         
 83  
     }
 84  
 
 85  
     public void decode(FacesContext facesContext, UIComponent component)
 86  
     {
 87  0
         RendererUtils.checkParamValidity(facesContext, component, UIInput.class);
 88  0
         HtmlRendererUtils.decodeUIInput(facesContext, component);
 89  0
     }
 90  
 
 91  
     public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException
 92  
     {
 93  0
         RendererUtils.checkParamValidity(facesContext, uiComponent, UIOutput.class);
 94  0
         return org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedUIOutputValue(facesContext,
 95  
                                                        (UIOutput)uiComponent,
 96  
                                                        submittedValue);
 97  
     }
 98  
 
 99  
 }