Coverage Report - org.apache.myfaces.renderkit.html.HtmlHiddenRenderer
 
Classes in this File Line Coverage Branch Coverage Complexity
HtmlHiddenRenderer
0%
0/20
0%
0/4
2
 
 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.renderkit.html;
 20  
 
 21  
 import java.io.IOException;
 22  
 
 23  
 import javax.faces.component.UIComponent;
 24  
 import javax.faces.component.UIInput;
 25  
 import javax.faces.component.UIOutput;
 26  
 import javax.faces.context.FacesContext;
 27  
 import javax.faces.context.ResponseWriter;
 28  
 import javax.faces.convert.ConverterException;
 29  
 
 30  
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
 31  
 import org.apache.myfaces.shared.renderkit.JSFAttr;
 32  
 import org.apache.myfaces.shared.renderkit.RendererUtils;
 33  
 import org.apache.myfaces.shared.renderkit.html.HTML;
 34  
 import org.apache.myfaces.shared.renderkit.html.HtmlRenderer;
 35  
 import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
 36  
 
 37  
 /**
 38  
  * 
 39  
  * @author Thomas Spiegl (latest modification by $Author$)
 40  
  * @author Anton Koinov
 41  
  * @version $Revision$ $Date$
 42  
  */
 43  
 @JSFRenderer(renderKitId = "HTML_BASIC", family = "javax.faces.Input", type = "javax.faces.Hidden")
 44  0
 public class HtmlHiddenRenderer extends HtmlRenderer
 45  
 {
 46  
     @Override
 47  
     public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException
 48  
     {
 49  0
         RendererUtils.checkParamValidity(facesContext, uiComponent, UIInput.class);
 50  
 
 51  0
         ResponseWriter writer = facesContext.getResponseWriter();
 52  
 
 53  0
         writer.startElement(HTML.INPUT_ELEM, uiComponent);
 54  0
         writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
 55  
 
 56  0
         String clientId = uiComponent.getClientId(facesContext);
 57  0
         writer.writeAttribute(HTML.ID_ATTR, clientId, null);
 58  0
         writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
 59  
 
 60  0
         String value = RendererUtils.getStringValue(facesContext, uiComponent);
 61  0
         if (value != null)
 62  
         {
 63  0
             writer.writeAttribute(HTML.VALUE_ATTR, value, JSFAttr.VALUE_ATTR);
 64  
         }
 65  
 
 66  0
         writer.endElement(HTML.INPUT_ELEM);
 67  0
     }
 68  
 
 69  
     @Override
 70  
     public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue)
 71  
         throws ConverterException
 72  
     {
 73  0
         RendererUtils.checkParamValidity(facesContext, uiComponent, UIOutput.class);
 74  0
         return RendererUtils.getConvertedUIOutputValue(facesContext, (UIOutput)uiComponent, submittedValue);
 75  
     }
 76  
 
 77  
     @Override
 78  
     public void decode(FacesContext facesContext, UIComponent component)
 79  
     {
 80  0
         RendererUtils.checkParamValidity(facesContext, component, null);
 81  
 
 82  0
         if (component instanceof UIInput)
 83  
         {
 84  0
             HtmlRendererUtils.decodeUIInput(facesContext, component);
 85  
         }
 86  
         else
 87  
         {
 88  0
             throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName());
 89  
         }
 90  0
     }
 91  
 
 92  
 }