📄 htmlmenurendererbase.java
字号:
/* * Copyright 2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.myfaces.renderkit.html;import org.apache.myfaces.renderkit.RendererUtils;import javax.faces.component.UIComponent;import javax.faces.component.UISelectMany;import javax.faces.component.UISelectOne;import javax.faces.component.html.HtmlSelectManyMenu;import javax.faces.component.html.HtmlSelectOneMenu;import javax.faces.context.FacesContext;import javax.faces.convert.ConverterException;import java.io.IOException;/** * X-CHECKED: tlddoc of h:selectManyListbox * * @author Manfred Geiler (latest modification by $Author: matze $) * @author Thomas Spiegl * @version $Revision: 1.4 $ $Date: 2004/10/13 11:51:01 $ * $Log: HtmlMenuRendererBase.java,v $ * Revision 1.4 2004/10/13 11:51:01 matze * renamed packages to org.apache * * Revision 1.3 2004/07/01 22:00:56 mwessendorf * ASF switch * * Revision 1.2 2004/06/04 00:26:16 o_rossmueller * modified renderes to comply with JSF 1.1 * * Revision 1.1 2004/05/18 14:31:39 manolito * user role support completely moved to components source tree * */public class HtmlMenuRendererBase extends HtmlRenderer{ //private static final Log log = LogFactory.getLog(HtmlMenuRenderer.class); public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException { RendererUtils.checkParamValidity(facesContext, component, null); if (component instanceof UISelectMany) { HtmlRendererUtils.renderMenu(facesContext, (UISelectMany)component, isDisabled(facesContext, component)); } else if (component instanceof UISelectOne) { HtmlRendererUtils.renderMenu(facesContext, (UISelectOne)component, isDisabled(facesContext, component)); } else { throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName()); } } protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent) { //TODO: overwrite in extended HtmlMenuRenderer and check for enabledOnUserRole if (uiComponent instanceof HtmlSelectManyMenu) { return ((HtmlSelectManyMenu)uiComponent).isDisabled(); } else if (uiComponent instanceof HtmlSelectOneMenu) { return ((HtmlSelectOneMenu)uiComponent).isDisabled(); } else { return RendererUtils.getBooleanAttribute(uiComponent, HTML.DISABLED_ATTR, false); } } private String getStyleClass(UISelectMany component) { if (component instanceof HtmlSelectManyMenu) { return ((HtmlSelectManyMenu)component).getStyleClass(); } else { return (String)component.getAttributes().get(HTML.STYLE_CLASS_ATTR); } } private String getStyleClass(UISelectOne component) { if (component instanceof HtmlSelectOneMenu) { return ((HtmlSelectOneMenu)component).getStyleClass(); } else { return (String)component.getAttributes().get(HTML.STYLE_CLASS_ATTR); } } public void decode(FacesContext facesContext, UIComponent uiComponent) { RendererUtils.checkParamValidity(facesContext, uiComponent, null); if (uiComponent instanceof UISelectMany) { HtmlRendererUtils.decodeUISelectMany(facesContext, uiComponent); } else if (uiComponent instanceof UISelectOne) { HtmlRendererUtils.decodeUISelectOne(facesContext, uiComponent); } else { throw new IllegalArgumentException("Unsupported component class " + uiComponent.getClass().getName()); } } public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException { RendererUtils.checkParamValidity(facesContext, uiComponent, null); if (uiComponent instanceof UISelectMany) { return RendererUtils.getConvertedUISelectManyValue(facesContext, (UISelectMany)uiComponent, submittedValue); } else if (uiComponent instanceof UISelectOne) { return RendererUtils.getConvertedUIOutputValue(facesContext, (UISelectOne)uiComponent, submittedValue); } else { throw new IllegalArgumentException("Unsupported component class " + uiComponent.getClass().getName()); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -