首页 文章

在Primefaces DataTable中表示布尔值

提问于
浏览
0

所以我试图将bean中的对象值传递给primefaces数据表(目前使用的是primefaces 3.4),但是我面临两个问题 .

1. 我似乎找不到任何方法来显示(或表示)数据表中列中的布尔值 . 每次我尝试这个时,表都返回完全为空(即使没有布尔列,其他列也会填充来自bean的数据) .

2. 另一个更大的问题(我认为与假设有关的java更多)是我目前从Siebels CRM ONDemand Cloud 解决方案获得的26个不同的对象,每个对象都包含自己的数据类型和属性值 . 我不能为我的生活弄清楚如何根据特定对象的下拉选择显示对象字段在primefaces数据表中动态 . 到目前为止,我已经设法显示其中一个对象的一些字段作为一种原型,但我遇到的问题是布尔值显示也是一个噩梦 .

有人有类似的经历吗?还是建议?我已经被这个困惑了超过2个星期了,我绝对疯了!

如果需要,我可以提供代码示例或其他详细信息:)

Thanks a lot I really appreciate any help !

雷吉

Html代码:

<p:panel header ="Source Environment" style="margin-bottom:5px;">
    <p:dataTable draggableColumns="true" id="tableFieldSet1" value="#{ODComBean.fields}" var="tableFieldSet1" rowKey="#{ODComBean.fields}" selectionMode ="multiple" style="font-family:sans-serif; width:max-content;">
        <p:panel header="OD Object Selection" style="margin-bottom:5px;">
            <h:panelGrid columns="2" cellpadding="5">
                <p:selectOneMenu immediate ="true" id="pickList" value="#{ODComBean.fieldSetData}" effect="fade"  style="font-size: 12px; font-family:sans-serif;" >
                    <f:selectItems value="#{ODComBean.fieldSet}"  itemLabel="#{fieldSet.objectName}" var="fieldSet"/>
                    <p:ajax event="change" update="@form" />
                </p:selectOneMenu>
            </h:panelGrid>
        </p:panel> 
        <p:panel header ="Source Environment" style="margin-bottom:5px;">          
            <p:dataTable draggableColumns="true" id="tableFieldSet1" value="#{ODComBean.fields}" var="tableFieldSet1" rowKey="#{ODComBean.fields}" selectionMode ="multiple" style="font-family:sans-serif; width:max-content;">     
                 <p:column headerText="Type"  styleClass="singleLine" style="height: 10px; font-size: 8pt;"> 
                     <h:outputText value="#{tableFieldSet1.fieldType}"/>
                 </p:column>
                  <p:column headerText="Required">
                         <p:graphicImage value="/resources/images/tick.png" rendered="#{tableFieldSet1.readOnly}"/>
                         <p:graphicImage value="/resources/images/red-cross.png" rendered="#{not tableFieldSet1.readOnly}"/>
                 </p:column>
                 <p:column headerText="Name"  styleClass="singleLine" style="height: 10px; font-size: 8pt;">
                     <h:outputText value="#{tableFieldSet1.name}"/>
                 </p:column>
                 <p:column headerText ="Display Name" styleClass="singleLine" style="height: 10px; font-size: 8pt;">
                     <h:outputText value="#{tableFieldSet1.displayName}"/>
                 </p:column>
                 <p:column headerText="Default Value"   styleClass="singleLine" style="height: 10px; font-size: 8pt;">
                     <h:outputText value="#{tableFieldSet1.defaultValue}"/>
                 </p:column>
                 <p:column headerText="Generic Integration Tag" styleClass="singleLine" style="height: 10px; font-size: 8pt;">
                     <h:outputText value="#{tableFieldSet1.genericIntegrationTag}"/>
                 </p:column>
                 <p:column headerText ="Integration Tag"  styleClass="singleLine" style="height: 10px; font-size: 8pt;">
                      <h:outputText value="#{tableFieldSet1.integrationTag}"/>
                 </p:column>
                 <p:column headerText ="Translations" styleClass="singleLine" style="height: 10px; font-size: 8pt;">
                     <h:outputText value="#{tableFieldSet1.listOfFieldTranslations}"/>
                 </p:column>
                 <p:column headerText ="Validation Error"  styleClass="singleLine" style="height: 10px; font-size: 8pt;">
                     <h:outputText value="#{tableFieldSet1.validationErrorMsg}"/>
                 </p:column>
                     <!-- When I add the next Column it will only show data for the first line, and display a <div half tag in the last column... strange... !-->

    </p:dataTable>
</p:panel>

2 回答

  • 0

    如果你想使用h:outputText,你可以将它的转换器设置为你实现的并在转换器内,决定显示值 . 否则,如果您想根据值查看图标,可以这样做:

    <p:column headerText="My Boolean Value">
       <p:graphicImage value="/resources/images/tick.png" rendered="#{MODEL.boolean}"/>
       <p:graphicImage value="/resources/images/red-cross.png"  rendered="#{not MODEL.boolean}"/>
    </p:column>
    

    我希望这是有帮助的 :)

  • 4

    将布局设置为内联的Output panel生成带有您提供的样式类的<span>标记 .

    例如,您可以使用框架提供的jquery-ui icons . 像这样:

    <p:outputPanel layout="inline" styleClass="ui-icon ui-icon-circle-check" rendered="#{project.inBudget}" />
    <p:outputPanel layout="inline" styleClass="ui-icon ui-icon-circle-close" rendered="#{!project.inBudget}" />
    

相关问题