Coverage Report - org.apache.myfaces.shared_impl.renderkit.html.HtmlMenuRendererBase
 
Classes in this File Line Coverage Branch Coverage Complexity
HtmlMenuRendererBase
0%
0/26
0%
0/16
4.75
 
 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  
 
 23  
 import javax.faces.component.UIComponent;
 24  
 import javax.faces.component.UISelectMany;
 25  
 import javax.faces.component.UISelectOne;
 26  
 import javax.faces.component.html.HtmlSelectManyMenu;
 27  
 import javax.faces.component.html.HtmlSelectOneMenu;
 28  
 import javax.faces.context.FacesContext;
 29  
 import javax.faces.convert.ConverterException;
 30  
 import java.io.IOException;
 31  
 
 32  
 /**
 33  
  * X-CHECKED: tlddoc of h:selectManyListbox
 34  
  *
 35  
  * @author Manfred Geiler (latest modification by $Author: matzew $)
 36  
  * @author Thomas Spiegl
 37  
  * @version $Revision: 597729 $ $Date: 2007-11-23 14:25:55 -0500 (Fri, 23 Nov 2007) $
 38  
  */
 39  0
 public class HtmlMenuRendererBase
 40  
         extends HtmlRenderer
 41  
 {
 42  
     //private static final Log log = LogFactory.getLog(HtmlMenuRenderer.class);
 43  
 
 44  
     public void encodeEnd(FacesContext facesContext, UIComponent component)
 45  
             throws IOException
 46  
     {
 47  0
         RendererUtils.checkParamValidity(facesContext, component, null);
 48  
 
 49  0
         if (component instanceof UISelectMany)
 50  
         {
 51  0
             HtmlRendererUtils.renderMenu(facesContext,
 52  
                                          (UISelectMany)component,
 53  
                                          isDisabled(facesContext, component));
 54  
         }
 55  0
         else if (component instanceof UISelectOne)
 56  
         {
 57  0
             HtmlRendererUtils.renderMenu(facesContext,
 58  
                                          (UISelectOne)component,
 59  
                                          isDisabled(facesContext, component));
 60  
         }
 61  
         else
 62  
         {
 63  0
             throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName());
 64  
         }
 65  0
     }
 66  
 
 67  
     protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent)
 68  
     {
 69  
         //TODO: overwrite in extended HtmlMenuRenderer and check for enabledOnUserRole
 70  0
         if (uiComponent instanceof HtmlSelectManyMenu)
 71  
         {
 72  0
             return ((HtmlSelectManyMenu)uiComponent).isDisabled();
 73  
         }
 74  0
         else if (uiComponent instanceof HtmlSelectOneMenu)
 75  
         {
 76  0
             return ((HtmlSelectOneMenu)uiComponent).isDisabled();
 77  
         }
 78  
         else
 79  
         {
 80  0
             return org.apache.myfaces.shared_impl.renderkit.RendererUtils.getBooleanAttribute(uiComponent, org.apache.myfaces.shared_impl.renderkit.html.HTML.DISABLED_ATTR, false);
 81  
         }
 82  
     }
 83  
 
 84  
     public void decode(FacesContext facesContext, UIComponent uiComponent)
 85  
     {
 86  0
         org.apache.myfaces.shared_impl.renderkit.RendererUtils.checkParamValidity(facesContext, uiComponent, null);
 87  
 
 88  0
         if (uiComponent instanceof UISelectMany)
 89  
         {
 90  0
             HtmlRendererUtils.decodeUISelectMany(facesContext, uiComponent);
 91  
         }
 92  0
         else if (uiComponent instanceof UISelectOne)
 93  
         {
 94  0
             HtmlRendererUtils.decodeUISelectOne(facesContext, uiComponent);
 95  
         }
 96  
         else
 97  
         {
 98  0
             throw new IllegalArgumentException("Unsupported component class " + uiComponent.getClass().getName());
 99  
         }
 100  0
     }
 101  
 
 102  
     public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException
 103  
     {
 104  0
         org.apache.myfaces.shared_impl.renderkit.RendererUtils.checkParamValidity(facesContext, uiComponent, null);
 105  
 
 106  0
         if (uiComponent instanceof UISelectMany)
 107  
         {
 108  0
             return org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedUISelectManyValue(facesContext,
 109  
                                                                (UISelectMany)uiComponent,
 110  
                                                                submittedValue);
 111  
         }
 112  0
         else if (uiComponent instanceof UISelectOne)
 113  
         {
 114  0
             return org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedUISelectOneValue(facesContext,
 115  
                                                            (UISelectOne)uiComponent,
 116  
                                                            submittedValue);
 117  
         }
 118  
         else
 119  
         {
 120  0
             throw new IllegalArgumentException("Unsupported component class " + uiComponent.getClass().getName());
 121  
         }
 122  
     }
 123  
 
 124  
 }