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

📄 htmltablerendererbase.java

📁 一个使用struts+hibernate+spring开发的完的网站源代码。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            writer.startElement(elemName, component);            if (header)            {                String headerStyleClass = getHeaderClass(component);                if (facet != null)                    renderTableHeaderRow(facesContext, writer, component, facet, headerStyleClass, colspan);                if (hasColumnFacet)                    renderColumnHeaderRow(facesContext, writer, component, headerStyleClass);            }            else            {                String footerStyleClass = getFooterClass(component);                if (hasColumnFacet)                    renderColumnFooterRow(facesContext, writer, component, footerStyleClass);                if (facet != null)                    renderTableFooterRow(facesContext, writer, component, facet, footerStyleClass, colspan);            }            writer.endElement(elemName);        }    }	/**	 * Renders the header row of the table being rendered.	 * @param facesContext the <code>FacesContext</code>.	 * @param writer the <code>ResponseWriter</code>.	 * @param component the <code>UIComponent</code> for whom a table is being rendered.	 * @param headerFacet the facet for the header.	 * @param headerStyleClass the styleClass of the header.	 * @param colspan the number of columns the header should span.  Typically, this is	 * the number of columns in the table.	 * @throws IOException if an exception occurs.	 */    protected void renderTableHeaderRow(FacesContext facesContext, ResponseWriter writer, UIComponent component,            UIComponent headerFacet, String headerStyleClass, int colspan) throws IOException    {        renderTableHeaderOrFooterRow(facesContext, writer, component, headerFacet, headerStyleClass, HTML.TH_ELEM,                colspan);    }	/**	 * Renders the footer row of the table being rendered.	 * @param facesContext the <code>FacesContext</code>.	 * @param writer the <code>ResponseWriter</code>.	 * @param component the <code>UIComponent</code> for whom a table is being rendered.	 * @param footerFacet the facet for the footer.	 * @param footerStyleClass the styleClass of the footer.	 * @param colspan the number of columns the header should span.  Typically, this is	 * the number of columns in the table.	 * @throws IOException if an exception occurs.	 */    protected void renderTableFooterRow(FacesContext facesContext, ResponseWriter writer, UIComponent component,            UIComponent footerFacet, String footerStyleClass, int colspan) throws IOException    {        renderTableHeaderOrFooterRow(facesContext, writer, component, footerFacet, footerStyleClass, HTML.TD_ELEM,                colspan);    }	/**	 * Renders the header row for the columns, which is a separate row from the header row for the	 * <code>UIData</code> header facet.	 * @param facesContext the <code>FacesContext</code>.	 * @param writer the <code>ResponseWriter</code>.	 * @param component the <code>UIComponent</code> for whom a table is being rendered.	 * @param headerStyleClass the styleClass of the header 	 * @throws IOException if an exception occurs.	 */    protected void renderColumnHeaderRow(FacesContext facesContext, ResponseWriter writer, UIComponent component,            String headerStyleClass) throws IOException    {        renderColumnHeaderOrFooterRow(facesContext, writer, component, headerStyleClass, true);    }	/**	 * Renders the footer row for the columns, which is a separate row from the footer row for the	 * <code>UIData</code> footer facet.	 * @param facesContext the <code>FacesContext</code>.	 * @param writer the <code>ResponseWriter</code>.	 * @param component the <code>UIComponent</code> for whom a table is being rendered.	 * @param footerStyleClass the styleClass of the footerStyleClass 	 * @throws IOException if an exception occurs.	 */    protected void renderColumnFooterRow(FacesContext facesContext, ResponseWriter writer, UIComponent component,            String footerStyleClass) throws IOException    {        renderColumnHeaderOrFooterRow(facesContext, writer, component, footerStyleClass, false);    }    private void renderTableHeaderOrFooterRow(FacesContext facesContext, ResponseWriter writer, UIComponent component,            UIComponent facet, String styleClass, String colElementName, int colspan) throws IOException    {        HtmlRendererUtils.writePrettyLineSeparator(facesContext);        writer.startElement(HTML.TR_ELEM, component);        writer.startElement(colElementName, component);        if (colElementName.equals(HTML.TH_ELEM))        {            writer.writeAttribute(HTML.SCOPE_ATTR, HTML.SCOPE_COLGROUP_VALUE, null);        }        writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer(colspan), null);        if (styleClass != null)        {            writer.writeAttribute(HTML.CLASS_ATTR, styleClass, null);        }        if (facet != null)        {            RendererUtils.renderChild(facesContext, facet);        }        writer.endElement(colElementName);        writer.endElement(HTML.TR_ELEM);    }    private void renderColumnHeaderOrFooterRow(FacesContext facesContext, ResponseWriter writer,             UIComponent component, String styleClass, boolean header) throws IOException    {        HtmlRendererUtils.writePrettyLineSeparator(facesContext);        writer.startElement(HTML.TR_ELEM, component);        for (Iterator it = component.getChildren().iterator(); it.hasNext();)        {            UIComponent uiComponent = (UIComponent) it.next();            if(uiComponent.isRendered())            {              if (uiComponent instanceof UIColumn)              {                  if (header)                  {                      renderColumnHeaderCell(facesContext, writer, uiComponent,                           ((UIColumn) uiComponent).getHeader(), styleClass, 0);                  }                  else                  {                      renderColumnFooterCell(facesContext, writer, uiComponent,                           ((UIColumn) uiComponent).getFooter(), styleClass, 0);                  }              }              else if (uiComponent instanceof UIColumns)              {                  UIColumns columns = (UIColumns) uiComponent;                  for (int i = 0, size = columns.getRowCount(); i < size; i++)                  {                      columns.setRowIndex(i);                      if (header)                      {                          renderColumnHeaderCell(facesContext, writer, columns, columns.getHeader(),                              styleClass, 0);                      }                      else                      {                          renderColumnFooterCell(facesContext, writer, columns, columns.getFooter(),                              styleClass, 0);                      }                  }                  columns.setRowIndex(-1);              }            }        }        writer.endElement(HTML.TR_ELEM);    }    /**     * Renders the header facet for the given <code>UIColumn</code>.     * @param facesContext the <code>FacesContext</code>.     * @param writer the <code>ResponseWriter</code>.     * @param uiColumn the <code>UIColumn</code>.     * @param headerStyleClass the styleClass of the header facet.     * @param colspan the colspan for the tableData element in which the header facet     * will be wrapped.     * @throws IOException     */    protected void renderColumnHeaderCell(FacesContext facesContext, ResponseWriter writer, UIColumn uiColumn,             String headerStyleClass, int colspan) throws IOException    {      renderColumnHeaderCell(facesContext, writer, uiColumn, uiColumn.getHeader(), headerStyleClass, colspan);    }    /**	 * Renders the header facet for the given <code>UIColumn</code>.	 * @param facesContext the <code>FacesContext</code>.	 * @param writer the <code>ResponseWriter</code>.	 * @param uiComponent the <code>UIComponent</code> to render the facet for.     * @param facet the <code>UIComponent</code> to render as facet.	 * @param headerStyleClass the styleClass of the header facet.	 * @param colspan the colspan for the tableData element in which the header facet	 * will be wrapped.	 * @throws IOException	 */    protected void renderColumnHeaderCell(FacesContext facesContext, ResponseWriter writer, UIComponent uiComponent,             UIComponent facet, String headerStyleClass, int colspan) throws IOException    {        writer.startElement(HTML.TH_ELEM, uiComponent);        if (colspan > 1)        {            writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer(colspan), null);        }        if (headerStyleClass != null)        {            writer.writeAttribute(HTML.CLASS_ATTR, headerStyleClass, null);        }        if (facet != null)        {            RendererUtils.renderChild(facesContext, facet);        }        writer.endElement(HTML.TH_ELEM);    }    /**     * Renders the footer facet for the given <code>UIColumn</code>.     * @param facesContext the <code>FacesContext</code>.     * @param writer the <code>ResponseWriter</code>.     * @param uiColumn the <code>UIComponent</code>.     * @param footerStyleClass the styleClass of the footer facet.     * @param colspan the colspan for the tableData element in which the footer facet     * will be wrapped.     * @throws IOException     */    protected void renderColumnFooterCell(FacesContext facesContext, ResponseWriter writer, UIColumn uiColumn,         String footerStyleClass, int colspan) throws IOException    {            renderColumnFooterCell(facesContext, writer, uiColumn, uiColumn.getFooter(), footerStyleClass, colspan);    }    	/**	 * Renders the footer facet for the given <code>UIColumn</code>.	 * @param facesContext the <code>FacesContext</code>.	 * @param writer the <code>ResponseWriter</code>.	 * @param uiComponent the <code>UIComponent</code> to render the facet for.     * @param facet the <code>UIComponent</code> to render as facet.	 * @param footerStyleClass the styleClass of the footer facet.	 * @param colspan the colspan for the tableData element in which the footer facet	 * will be wrapped.	 * @throws IOException	 */    protected void renderColumnFooterCell(FacesContext facesContext, ResponseWriter writer, UIComponent uiComponent,         UIComponent facet, String footerStyleClass, int colspan) throws IOException    {        writer.startElement(HTML.TD_ELEM, uiComponent);        if (colspan > 1)        {            writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer(colspan), null);        }        if (footerStyleClass != null)        {            writer.writeAttribute(HTML.CLASS_ATTR, footerStyleClass, null);        }        if (facet != null)        {            RendererUtils.renderChild(facesContext, facet);        }        writer.endElement(HTML.TD_ELEM);    }	/**	 * Gets the headerClass attribute of the given <code>UIComponent</code>.	 * @param component the <code>UIComponent</code>.	 * @return the headerClass attribute of the given <code>UIComponent</code>.	 */    protected static String getHeaderClass(UIComponent component)    {        if (component instanceof HtmlDataTable)        {            return ((HtmlDataTable) component).getHeaderClass();        }        else        {            return (String) component.getAttributes().get(JSFAttr.HEADER_CLASS_ATTR);        }    }	/**	 * Gets the footerClass attribute of the given <code>UIComponent</code>.	 * @param component the <code>UIComponent</code>.	 * @return the footerClass attribute of the given <code>UIComponent</code>.	 */    protected static String getFooterClass(UIComponent component)    {        if (component instanceof HtmlDataTable)        {            return ((HtmlDataTable) component).getFooterClass();        }        else        {            return (String) component.getAttributes().get(JSFAttr.FOOTER_CLASS_ATTR);        }    }    //-------------------------------------------------------------    // Helper class Styles    //-------------------------------------------------------------    private static class Styles    {        //~ Instance fields        // ------------------------------------------------------------------------        private String[] _columnStyle;        private String[] _rowStyle;        //~ Constructors        // ---------------------------------------------------------------------------        Styles(String rowStyles, String columnStyles)        {            _rowStyle = (rowStyles == null) ? ArrayUtils.EMPTY_STRING_ARRAY : StringUtils.trim(StringUtils                    .splitShortString(rowStyles, ','));            _columnStyle = (columnStyles == null) ? ArrayUtils.EMPTY_STRING_ARRAY : StringUtils.trim(StringUtils                    .splitShortString(columnStyles, ','));        }        public String getRowStyle(int idx)        {            if (!hasRowStyle())            {                return null;            }            return _rowStyle[idx % _rowStyle.length];        }        public String getColumnStyle(int idx)        {            if (!hasColumnStyle())            {                return null;            }            return _columnStyle[idx % _columnStyle.length];        }        public boolean hasRowStyle()        {            return _rowStyle.length > 0;        }        public boolean hasColumnStyle()        {            return _columnStyle.length > 0;        }    }    public void decode(FacesContext context, UIComponent component)    {        super.decode(context, component);    }}

⌨️ 快捷键说明

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