2
votes

So I am attempting to pass object values from a bean into a primefaces datatable (using primefaces 3.4 currently), howevever I'm facing two problems with this.

1. I cannot seem to find any way to display (or represent) a boolean value within a column in a datatable. Every time I attempt this, the table returns back totally empty (even though without the boolean column the other columns are populated with data from the bean).

2. The other bigger problem (more to do with java I think than primefaces) is that I have currently 26 different Objects I get from Siebels CRM ONDemand cloud solution, each containing their own datatypes and attribute values. I cannot for the life of me figure out how to, based on a drop down selection of a specific object display that objects fields dynamically within a primefaces datatable. So far I have just managed to display some of the fields for 1 of these objects as a sort of prototype but I am having the problem with the boolean value being display also its a nightmare.

Anybody have any sort of similar experiences ? or suggestions? I've been puzzled by this for over 2 weeks now and I am going absolutely crazy!

I can provide code examples or other details if needed :)

Thanks a lot I really appreciate any help !

Reggie

Html code:

<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>
3
I can't imagine how a boolean property can ever form a problem this way. An SSCCE would be helpful in better understanding the concrete problem. - BalusC
Hi Balus, Unfortunately I don't know If I could provide a SSCCE as you would need the WSDL (Web service Description Lanaguage File) which I use to get the objects, Or at least not a compilable one. I could however copy a snippet of my xhtml and the backing bean which are relevant and maybe you can spot some sort of mistake I've made?? If at all possible,, Thanks for response ;) - reggie morgan
If you can't just stub it yourself, then it would most likely not be a JSF specific problem. - BalusC
I think it's more I have no idea how to put for example a check box within a column and use a boolean valued variable to define if its ticked or not (true or false). Currently Im trying to display the boolean value within a h:outputText tag which I believe is probably incorrect :/ - reggie morgan
Seems like an exception was thrown in midst of rendering, probably due to a syntax error or incomplete code in the markup. Have you for instance looked at the server logs? The exception should be logged there. Otherwise increase response buffer size by javax.faces.FACELETS_BUFFER_SIZE context param so that the exception will be shown in its entirety in an error page. - BalusC

3 Answers

6
votes

if you want to use a h:outputText, you can set its converter to something that you implemented and inside that converter, decide about the display value. Otherwise, if you like to view an icon according to the value, you can do like this :

<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>

I hope this is helpful :)

0
votes

Output panel with layout set to inline produce a <span> tag with the style class you provide.

You can for example use the jquery-ui icons provided by the framework. Like this:

<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}" />
0
votes

You could simply use a check mark symbol for true and empty String, or x symbol for false.

<p:column headerText="Required" style="text-align: center">
    <h:outputText value="#{tableFieldSet1.readOnly ? '✓' : ''}"/>
</p:column>