0

Hello I'm having a trouble with using datagrid since there is no "built in" function to filter the datagrid list.

So i read from here and tried to applied it in my project.

This is my HomeMBean.java looks like

 private List<LowonganKerja> names = new ArrayList<LowonganKerja>();
 private List<Kabupaten> filterednames = new ArrayList<Kabupaten>();
 private String filterValue;
 

public void filterList() {

    List<String> filteredList = Lists.newArrayList(Collections2.filter(getNames(), Predicates.containsPattern(filterValue)));
    setFilterednames(filteredList);
}

and this is my xhtml file

<p:panelGrid id="idPgGridSearch" columns="2" layout="grid" styleClass="ui-panelgrid-blank form-group" 
                             columnClasses="ui-grid-col-6,ui-grid-col-6">
                    <h:outputText value="#{homeMBean.listLowonganKerja.dataSize} Lowongan yang tersedia" 
                                  style="font-weight: bold;margin-left: 5px;"/>
                    <p:panelGrid id="idPgGrid" columns="2" layout="grid" styleClass="ui-panelgrid-blank form-group" 
                                 columnClasses="ui-grid-col-4,ui-grid-col-8">
                        <p:outputLabel value="Cari Wilayah Lowongan :" style="font-weight: bold;"/>
                        <p:inputText value="#{bean.filterValue}">
                            <p:ajax event="keyup" update="lowonganGrid" listener="#{bean.filterList()}" />
                        </p:inputText>
                    </p:panelGrid>
                </p:panelGrid>

the error said "method filter in class collections2 cannot be applied to given types;"

and i tried to do the same like that reference link, by changing it to String

private List<String> names = new ArrayList<String>();
private List<String> filterednames = new ArrayList<String>();
private String filterValue;

#edit error message is this

image

Anyone knows why ? or do you have other references how to make filter in datagrid with input text?

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
Maxes
  • 13
  • 4

0 Answers0