0

I have a list of objects in a bean and I would like to display this list into a dataTable. Each row contains data of the object. But, i don't want to display all the objets in my dataTable.

<rich:dataTable id="myTable" iterationStatusVar="iterator" style="width: 100%; height: 100%" value="#{myBean.myList}" var="myObject">
                <rich:column>
                    <f:facet name="header">
                        <h:outputLabel value="#{bundle.name}"/>
                    </f:facet>
                    <h:outputLabel value="#{myObject.name}" rendered = "#{myObject.code == bundle.code}"/>
                </rich:column>
                <rich:column>
                    <f:facet name="header">
                        <h:outputLabel value="#{bundle.type}"/>
                    </f:facet>
                    <h:outputLabel value="#{myObject.type}" 
                        rendered = "#{myObject.code== bundle.code}"/>
                </rich:column>
            </rich:dataTable>

This code displays only the objects which have myObject.code== bundle.code. But, my data table displays the others rows too (the columns are not informed).

Could you help me, please?

Thank you.

TronchDeYack
  • 33
  • 13

1 Answers1

0

Your bean could offer a method returning a filtered List, containing the desired objects only. Display that filtered list in your dataTable.

Or you could use an EL expression to filter the list, if you use the current EL version 3.0. #{myBean.myList.stream().filter(o->o.code == bundle.code)}"#

  • Thank you for your answer. I have add a method into my bean which returns a filtered list. But i don't know how can i call it. Can you help me? My method is public List filterList(String pCode). How could i call it in my jsf? I don't know how to add parameter. – TronchDeYack Nov 06 '13 at 13:27
  • Does this work `` – user2960290 Nov 06 '13 at 14:36
  • You may also have a loot at this: http://stackoverflow.com/questions/5273729/how-to-call-a-method-with-a-parameter-in-jsf – user2960290 Nov 06 '13 at 15:05