⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htmltabbedpanerenderer.java

📁 一个使用struts+hibernate+spring开发的完的网站源代码。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * 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.custom.tabbedpane;import org.apache.myfaces.renderkit.RendererUtils;import org.apache.myfaces.renderkit.html.HTML;import org.apache.myfaces.renderkit.html.HtmlRenderer;import org.apache.myfaces.renderkit.html.HtmlRendererUtils;import org.apache.myfaces.component.UserRoleUtils;import javax.faces.application.ViewHandler;import javax.faces.component.NamingContainer;import javax.faces.component.UIComponent;import javax.faces.component.UIForm;import javax.faces.component.UIViewRoot;import javax.faces.component.UINamingContainer;import javax.faces.context.FacesContext;import javax.faces.context.ResponseWriter;import java.io.IOException;import java.util.List;import java.util.Map;/** * @author Manfred Geiler (latest modification by $Author: oros $) * @version $Revision: 1.10 $ $Date: 2005/02/16 00:50:37 $ * $Log: HtmlTabbedPaneRenderer.java,v $ * Revision 1.10  2005/02/16 00:50:37  oros * SF issue #1043331: replaced all &nbsp; by the corresponding numeric entity &#160; so safari users will be happy, too, with MyFaces output * * Revision 1.9  2005/02/11 16:03:00  mmarinschek * solve bug in tabbed panel when datatable was displayed not on tab, but at the bottom of the datatable... * * Revision 1.8  2005/01/24 12:20:11  mmarinschek * Changed the TabbedPane component to only decode components which are on the visible tags - other components are not processed in the decode phase. Changed the HtmlRendererUtils back to submit empty strings for components which should be posted back but have null values. * * Revision 1.7  2004/11/26 14:29:12  oros * bug fix #1006636: VisibleOnUserRole attribute for x:panelTab tag * * Revision 1.6  2004/10/13 11:50:58  matze * renamed packages to org.apache * * Revision 1.5  2004/08/09 10:52:25  manolito * RFE #975649 - Enhance HtmlTabbedPaneRenderer (rendered attribute for TabbedPane component) * * Revision 1.4  2004/07/10 17:11:02  o_rossmueller * added attributes activeTabStyleClass, inactiveTabStyleClass, activeSubStyleClass, inactiveSubStyleClass, tagContentStyleClass to overwrite style attributes using css * * Revision 1.3  2004/07/01 21:53:05  mwessendorf * ASF switch * * Revision 1.2  2004/05/18 12:02:13  manolito * getActionURL and getResourceURL must not call encodeActionURL or encodeResourceURL * */public class HtmlTabbedPaneRenderer        extends HtmlRenderer{    //private static final Log log = LogFactory.getLog(HtmlTabbedPaneRenderer.class);    private static final String TABLE_STYLE =        "border-style: none; " +        "padding: 0px; " +        "border-spacing: 0px; " +        "empty-cells: show; ";    private static final String ACTIVE_HEADER_CELL_STYLE =        "border-top: 2px outset #CCCCCC; " +        "border-right: 2px outset #CCCCCC; " +        "border-bottom: 0px none; " +        "border-left: 2px outset #CCCCCC; " +        "text-align: center; ";    private static final String INACTIVE_HEADER_CELL_STYLE =        "border-top: 1px outset #CCCCCC; " +        "border-right: 1px outset #CCCCCC; " +        "border-bottom: 0px none; " +        "border-left: 1px outset #CCCCCC; " +        "text-align: center; " +        "background-color: #CCCCCC; ";    private static final String EMPTY_HEADER_CELL_STYLE =        "border-top: 0px none; " +        "border-right: 0px none; " +        "border-bottom: 0px none; " +        "border-left: 0px none; ";    private static final String SUB_HEADER_CELL_STYLE =        "height: 2px; " +        "line-height: 0px; font-size: 0px; " +        "border-bottom: 0px none; ";    private static final String TAB_CELL_STYLE =        "border-top: 0px none; " +        "border-right: 2px outset #CCCCCC; " +        "border-bottom: 2px outset #CCCCCC; " +        "border-left: 2px outset #CCCCCC; " +        "padding: 10px; ";    private static final String NO_BORDER_STYLE =        "0px none; ";    private static final String BORDER_STYLE =        "2px outset #CCCCCC; ";    private static final String BUTTON_STYLE_ACTIVE        = "border-style:none; width:100%; cursor:pointer;";    private static final String BUTTON_STYLE_INACTIVE        = "border-style:none; width:100%; cursor:pointer; background-color:#CCCCCC;";    private static final String BUTTON_STYLE_DISABLED        = "border-style:none; width:100%; cursor:normal;";    private static final String DEFAULT_BG_COLOR = "#FFFFFF";    private static final String AUTO_FORM_SUFFIX = ".autoform";    public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException    {    }    public boolean getRendersChildren()    {        return true;    }        public void encodeChildren(FacesContext facescontext, UIComponent uicomponent) throws IOException    {    }    public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException    {        RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlPanelTabbedPane.class);        ResponseWriter writer = facesContext.getResponseWriter();        HtmlRendererUtils.writePrettyLineSeparator(facesContext);        HtmlPanelTabbedPane tabbedPane = (HtmlPanelTabbedPane)uiComponent;        int selectedIndex = tabbedPane.getSelectedIndex();        if (tabbedPane.getBgcolor() == null)        {            tabbedPane.setBgcolor(DEFAULT_BG_COLOR);        }        UIForm parentForm = RendererUtils.findParentForm(tabbedPane);        if (parentForm == null)        {            writeFormStart(writer, facesContext, tabbedPane);        }        writeTableStart(writer, facesContext, tabbedPane);        HtmlRendererUtils.writePrettyLineSeparator(facesContext);        writer.startElement(HTML.TR_ELEM, uiComponent);        //Tab headers        int tabIdx = 0;        int visibleTabCount = 0;        int visibleTabSelectedIdx = -1;        List children = tabbedPane.getChildren();        for (int i = 0, len = children.size(); i < len; i++)        {            UIComponent child = getUIComponent((UIComponent)children.get(i));            if (child instanceof HtmlPanelTab)            {                if (child.isRendered())                {                    writeHeaderCell(writer, facesContext, tabbedPane,                                    (HtmlPanelTab)child, tabIdx, tabIdx == selectedIndex, isDisabled(facesContext, child));                    if (tabIdx == selectedIndex)                    {                        visibleTabSelectedIdx = visibleTabCount;                    }                    visibleTabCount++;                }                tabIdx++;            }        }        //Empty tab cell on the right for better look        HtmlRendererUtils.writePrettyLineSeparator(facesContext);        HtmlRendererUtils.writePrettyIndent(facesContext);        writer.startElement(HTML.TD_ELEM, uiComponent);        writer.writeAttribute(HTML.STYLE_ATTR, EMPTY_HEADER_CELL_STYLE, null);        writer.write("&#160;");        writer.endElement(HTML.TD_ELEM);        HtmlRendererUtils.writePrettyLineSeparator(facesContext);        writer.endElement(HTML.TR_ELEM);        //Sub header cells        HtmlRendererUtils.writePrettyLineSeparator(facesContext);        writer.startElement(HTML.TR_ELEM, uiComponent);        writeSubHeaderCells(writer,  facesContext, tabbedPane, visibleTabCount, visibleTabSelectedIdx, false);        HtmlRendererUtils.writePrettyLineSeparator(facesContext);        writer.endElement(HTML.TR_ELEM);        //Tab        HtmlRendererUtils.writePrettyLineSeparator(facesContext);        writer.startElement(HTML.TR_ELEM, uiComponent);        writeTabCell(writer,  facesContext, tabbedPane, visibleTabCount, selectedIndex);        HtmlRendererUtils.writePrettyLineSeparator(facesContext);        writer.endElement(HTML.TR_ELEM);        HtmlRendererUtils.writePrettyLineSeparator(facesContext);        writer.endElement(HTML.TABLE_ELEM);        if (parentForm == null)        {            writeFormEnd(writer, facesContext);        }    }    public void decode(FacesContext facesContext, UIComponent uiComponent)    {        RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlPanelTabbedPane.class);        HtmlPanelTabbedPane tabbedPane = (HtmlPanelTabbedPane)uiComponent;        Map paramMap = facesContext.getExternalContext().getRequestParameterMap();        int tabIdx = 0;        List children = tabbedPane.getChildren();        for (int i = 0, len = children.size(); i < len; i++)        {            UIComponent child = getUIComponent((UIComponent)children.get(i));            if (child instanceof HtmlPanelTab)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -