1

i have a parent class including two others that inherit from this parent class and i retrieve a list of objects from this parent class and I have a datatable share in two parts using column group to represent each object that arise from the parent and at the datatable i want to add a condition for example if this object is X display it in the column of X otherwise I display it in the column of Y.

Here is my dataTable

 <p:dataTable var="etp" value="#{etpBean.etps}">
    <f:facet name="header">
        Equivalent temps de travail
    </f:facet>

    <p:columnGroup type="header">
        <p:row>
            <p:column rowspan="3" headerText="Ressource" />
            <p:column colspan="4" headerText="Centre des coûts" />
        </p:row>
        <p:row>
            <p:column colspan="3" headerText="Activite" />
            <p:column colspan="3" headerText="Projet" />
        </p:row>
        <p:row>
            <p:column headerText="Nom" />
            <p:column headerText="Prise en charge" />
            <p:column headerText="Charge réelle" />
            <p:column headerText="Nom" />
            <p:column headerText="Prise en charge" />
            <p:column headerText="Charge réelle" />
        </p:row>
    </p:columnGroup>



    <p:column>
        <h:outputText value="#{etp.affectation.ressource.nom}" />
    </p:column>

    <!-- Here I display the first object -->

    <p:column>
        <h:outputText value="#{etp.parent.nom}" />
    </p:column>


    <p:column>
        <h:outputText value="#{etp.etp}%" />
    </p:column>

    <p:column>
        <h:outputText value="#{etp.chargeActivite}%" />
    </p:column>



    <!-- Here I display the second object -->

     <p:column>
        <h:outputText value="#{etp.parent.nom}" />
    </p:column>


    <p:column>
        <h:outputText value="#{etp.etp}%" />
    </p:column>

    <p:column>
        <h:outputText value="#{etp.chargeActivite}%" />
    </p:column>



    <p:columnGroup type="footer">
        <p:row>
            <p:column colspan="2" footerText="Totals:" />
            <p:column footerText="" />
            <p:column footerText="$#{etpBean.chargeTotal}%" />
        </p:row>
    </p:columnGroup>


</p:dataTable>

For the moment the data are duplicate on the columns and this normal This is normal since i do not make any conditions

And i want to group this column on the whole list of objects since it will repeat the same on all lines

<p:column>
    <h:outputText value="#{etp.affectation.ressource.nom}" />
</p:column>
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
CHARAFI Saad
  • 1,340
  • 3
  • 16
  • 36
  • 1
    Your question is not clear. Are you asking if you have list of objects of Classs X and class Y and both classes are inherited from Parent. How can you identify whether its instance of class X or Class Y? – Sumit Gulati Apr 12 '17 at 00:01
  • @Sumit Thank u for ur response i choose the strategy of a single table for the whole hierarchy and I have a discriminator, when I insert the object X in the database on table parent takes X as discriminator and even case for Y – CHARAFI Saad Apr 12 '17 at 00:16
  • 1
    If I am getting you want to check the obj instanceof X or obj instanceof Y in primefaces EL? If yes you can check using the type attribute. – Sumit Gulati Apr 12 '17 at 02:40
  • 2
    @CHARAFISaad thanks for explaining further. I would be better though to improve your question. Also, adding some interpunction might make it more digestible. – Jasper de Vries Apr 12 '17 at 07:14
  • 2
    .. and please carefully read how to create a [mcve] – Jasper de Vries Apr 12 '17 at 07:15
  • why not use rendered? – kinkajou Apr 12 '17 at 14:39

0 Answers0