p:column header facet is not shown when rendered attribute is used on p:column

旧街凉风 提交于 2019-12-24 03:07:24

问题


I have a <p:dataTable>. I would like to render a <p:column> conditionally as follows:

<p:dataTable value="#{abcList}" var="abc">
  <p:column rendered="#{headerShow}">
    <f:facet name="header">
      <h:outputText value="header" />
    </f:facet>
    <h:outputText value="#{abc.hijk}" />
  </p:column>
</p:dataTable>

When #{headerShow} is false, then the column is hidden. When #{headerShow} is true, then the column is shown, but without header. When I hardcode rendered="true", then the column is shown with header.

How is this caused and how can I solve it?


回答1:


<f:facet name="header"> is outdated for column names. Primefaces 3.0 introduced the headerText attribute doing exactly the same.

So try this instead:

<p:column rendered="#{headerShow}" headerText="header">
  <h:outputText value="#{abc.hijk}" />
</p:column>


来源:https://stackoverflow.com/questions/12948799/pcolumn-header-facet-is-not-shown-when-rendered-attribute-is-used-on-pcolumn

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!