1

I have a .xhtml model with a primeface datatable in it. I call the page with an URL like this: http://localhost:8080/myproject/mypage.jsf?Id=51&startDate=04-05-2015&name=whatever

The URL parameters are used to retrieve what will be displayed in the datatable, so it allow me to filter the content. I used URL parameter because this page is displayed when I select a row in another datable so I have to make a manual redirect to this page on the baking bean.

However everytime I use one of primeface functionality like sorting or pagination primeface seems to do an ajax call to the backing bean but WITHOUT the parameters, so every object are displayed instead of a filtered list of Objects.

Therefore how can I force primefaces to use these parameters? Or how can I pass them to primefaces scope (they are @ManagedProperty on the backing bean)

Cœur
  • 37,241
  • 25
  • 195
  • 267
golgoth
  • 15
  • 6

1 Answers1

3

The best and easiest way is to use the OmniFaces utility library and more specifically their <o:form>.

From the documentation:

The <o:form> is a component that extends the standard <h:form> and provides a way to keep view or request parameters in the request URL after a post-back

...

You can use it the same way as <h:form>, you only need to change h: to o:.

So, replace your <h:form> by either

<o:form includeRequestParams="true">

or

<o:form useRequestURI="true">

See also:

Community
  • 1
  • 1
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • That exactly did the trick, thanks! And since it doesn't overlap with PrimeFace functionality it isn't a problem to add OmniFace to the project. The good beeing it forced me to finally use CDI ^^ – golgoth Jun 05 '15 at 08:47
  • it is even a good choice to add OmniFaces. Lots of convenience things – Kukeltje Jun 05 '15 at 10:30
  • @BalusC Huumm i have a strange bug on the datatable wich is within the o:form having includeRequestParams="true" (same with ). Sorting is removing the PrimeFace Datatable Filtering. I can sort alone and filter alone without problem, but when i sort the datable after filtering it it remove the filter. Clicking again on the same filter won't do anything but filtering on another value will display the expected result. Any clue? – golgoth Jun 06 '15 at 09:16
  • Please ask new questions in a new question. And in that new question, also post version info – Kukeltje Jun 06 '15 at 09:38