0

假设我有这个:

<p:column headerText="R"
          style=" text-align: center;"
          width="10"
          rendered="true">
  <p:commandLink id="MRepShowButton" update=":form1:display" onclick="EditorDialog.show();"  title="Editer le compte rendu"> 
  <f:setPropertyActionListener value="#{exam}" target="#{dyna.selectedExamen}" />  
     <p:graphicImage id="img1" value="/images/study_Report_icons/Text/0.png" rendered="#{exam.examen.rapport.rapportWrittenState == null}"/>
     <p:graphicImage id="img2" value="/images/study_Report_icons/Text/#{exam.examen.rapport.rapportWrittenState}.png" rendered="#{exam.examen.rapport.rapportWrittenState != null}"/>
  </p:commandLink>
</p:column> 

现在我怎样才能使用<p:columns>

<p:columns value="#{tableBean.columns}" var="column" columnIndexVar="colIndex" 
           sortBy="#{column.property}" filterBy="#{column.property}">
                    <f:facet name="header">
                        #{column.header}
                    </f:facet>

                    #{car[column.property]}

                </p:columns>

关于这个主题的所有示例和教程只涵盖了简单的<h:outptText>组件(p:graphicImage、p:commandLink 等)嵌套在一个列中,如上面的代码。你是怎么做到的?

4

1 回答 1

1

您可以呈现 <p:columns> 元素内的任何元素。

您想要做的可能是根据列以不同的方式呈现单元格内容。你可以尝试这样的事情:

  //classic rendering (for all cells)
  <h:outputText value="#{car[column.property]}"/>

  //conditional rendering (for 'report' cells only)
  <h:panelGroup rendered="#{column.property == 'report'}">
    <p:commandLink id="MRepShowButton" update=":form1:display" onclick="EditorDialog.show();"  title="Editer le compte rendu">
      <f:setPropertyActionListener value="#{exam}" target="#{dyna.selectedExamen}" />  
      <p:graphicImage id="img1" value="/images/study_Report_icons/Text/0.png" rendered="#{exam.examen.rapport.rapportWrittenState == null}"/>
      <p:graphicImage id="img2" value="/images/study_Report_icons/Text/#{exam.examen.rapport.rapportWrittenState}.png" rendered="#{exam.examen.rapport.rapportWrittenState != null}"/>
    </p:commandLink>
  </h:panelGroup>
于 2013-12-26T20:51:37.967 回答