【问题标题】:Rich Faces dataTable header StyleClass issueRich Faces 数据表标题 StyleClass 问题
【发布时间】:2014-06-05 06:18:00
【问题描述】:

版本:

Apache MyFaces 2.1.14 RichFaces 4.3.5

问题:

我们正在从 jsf 1.2 迁移到 jsf 2。

我提出了一个关于样式表的类似问题here。 问题是相同的样式(根据上述问题中的答案)在另一个 rich:dataTable 组件中没有生效。 最后,内置的 Richfaces 样式表的工作方式如下面的代码所示。 为表头生成的 html 代码也显示在rf-dt-shdr-c(解决问题的内置样式表更改)出现的位置。

所以问题是: 为什么相同的rich:dataTable 组件具有相同的样式生成的html 不同。 在这个 rich:dataTable 中添加的唯一变化是排序行为,如下面的代码所示:

代码:

<!-- rich faces built in style (worked )-->
.rf-dt-shdr-c{
    background-image:url(../images/heading-bg.gif) !important;
    background-position: left top !important;
    background-color: #FFFFFF !important;
    white-space:nowrap !important;
}



  <!-- header class  (not working ) -->
   .headerClass1 {
        background-image:url(../images/heading.gif);
        background-color: #FFFFFF;
        background-position:top left;
        background-repeat:repeat-x;
    }

<!-- rich dataTable with column sorting using a4j:commandLink in header -->



 <rich:dataTable value="#{bean.data}" var="val" styleClass="adminTable1"    headerClass="headerClass1" rows="#{bean.rowsPerPage}" rowClasses="oddRow,evenRow" render="requests" index="index"> 
            <c:forEach items="#{items}" var="column">                       

            <rich:column sortBy="" sortOrder="">    
                  <f:facet name="header">                       
                    <a4j:commandLink/>
                  </f:facet>
            </rich:column>
        </c:forEach>
    </rich:dataTable>


<!-- html generated for table header part for this question  (rf-dt-hdr richDataTableHeader1 is missing here whereas rf-dt-shdr-c comes into play ) -->
<thead class="rf-dt-thd" id="sampleForm:req:th"> 
    <tr class="rf-dt-shdr" id="sampleForm:req:ch">
        <th class="rf-dt-shdr-c" id="sampleForm:req:j_id_1d_1_w_1" scope="col">


<!-- html generated for other rich:dataTables , -->
<thead class="rf-dt-thd" id="profForm:app:th">
    <tr class="rf-dt-hdr richDataTableHeader1 rf-dt-hdr-fst" id="profForm:app:0">
        <th class="rf-dt-hdr-c" id="profForm:app:j_id_67">

【问题讨论】:

    标签: jsf-2 richfaces


    【解决方案1】:

    您正在尝试为没有定义标题的表设置 headerClass。您应该在列上设置标题类,因为这些是带有标题的元素。

    【讨论】:

    • 感谢 Makhiel 的回复。我已经更新了问题以变得更加清晰。 rich:dataTable 确实有 headerClass 和 styleClass 属性,但它们仍然没有生效
    • 因为headerClass没地方放。表中没有&lt;f:facet name="header"&gt;,只有列中。
    • 非常感谢 Makhiel。将 headerClass 添加到 rich:column 解决了这个问题。我非常感谢您在富人面孔问题上的帮助,我现在也很好地了解了富人面孔样式以及它们的工作原理。谢谢。
    猜你喜欢
    • 2014-06-01
    • 1970-01-01
    • 2011-11-21
    • 2011-08-25
    • 2013-04-11
    • 2015-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多