1
votes

I'm fairly new to using primefaces, and have a little doubt (already asked it on the primefaces forum but no reply so far)

Is it possible to get the filter value on a xls dataExporter, more concretely on a postprocessor like method?

I can get the filtered value by declaring the filteredValue on the dataTable. But the filterValue variable isn't working as expected.

I have both declared on my dataTable like this:

filteredValue="#{parqueController.parqueListFiltered}" filterValue="#{parqueController.parqueListFilter}"

When I filter the values, the setter on the Bean class fires only for the filtered value, making the filter value always null.

I ended finding this thread on PrimeFaces concerning this:

https://code.google.com/archive/p/primefaces/issues/5361

The issue was reported on version 3.5 and, as it looks, it was corrected/altered for later versions.. I'm using version 5.3

Think this might be a bug? a regression? or am i just missing a point here and doing something wrong?

enter image description here

Best regards and Thank you!

Miguel Palmeiro

1

1 Answers

1
votes

After finding this awkwardly weird.. downloading Primefaces sources.. debuging.. got to the conclusion that the filtervalue is declared on the column (if i wasnt kinda distracted would've noticed it faster.. ^^)

  <p:column style="width: 20%" filterBy="#{parque.id}" sortBy="#{parque.id}" filterValue="#{parqueController.parqueListFilter}" filterMatchMode="contains">

after that the value gets returned as an individual string for each column, empty for no value and value for.. value ^^. On this stage treat it as needed.. I ended creating a List with all of the filter values.. on the excel postprocessor, always take the last 4 values from the list and iterate on those 4 values, knowing my columns are fixed..

What I meant was that the filteredValue=#{classController.variable} points to where you want the values to go in my case after i got the filtered values in parqueListFilter i did like this:

List<String> tail = parqueListFilters.subList(Math.max(parqueListFilters.size() - 4, 0), parqueListFilters.size());

But still that variable should be filled on the backend part of the application after a filtering has occured on the frontend zone.

public List<String> parqueListFilters = new ArrayList<String>() ;

public String getParqueListFilter() {
    return parqueListFilter;
}

public void setParqueListFilter(String parqueListFilter) {
    this.parqueListFilter = parqueListFilter;
    parqueListFilters.add(parqueListFilter);
}