2

I'm using JSF2.2 and PrimeFaces 5.2 and I have a list of chackboxes which posts a request via

<p:ajax  listener="#{packageListBean.filterResults()}" update="@form" process="@this"/>

Every time a post happens the @PostConstruct method of the been is invoked but not the listener.

the bean is anotated with :

import javax.faces.view.ViewScoped;
import javax.inject.Named;

It is very strange as I would expect the @PostConstruct method to be invoked only on the first GET reqest of the page.

Added after BalusC comment:

I'm including jquery like this:

<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />

If I issue the request by f:ajax then the code works ok and @PostConstruct is called only once and also the listener is called.

This is the request made with p:ajax

POST /index.jsf HTTP/1.1
Host: cloudflow-backend-local.arctur.net:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
Accept: application/xml, text/xml, */*; q=0.01
Accept-Language: sl,en-GB;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Faces-Request: partial/ajax
X-Requested-With: XMLHttpRequest
Referer: http://cloudflow-backend-local.arctur.net:8080/index.jsf
Content-Length: 280
Cookie: lng=sl; **************.*****
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache

and this is a request made by f:ajax

POST /index.jsf HTTP/1.1
Host: cloudflow-backend-local.arctur.net:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: sl,en-GB;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Faces-Request: partial/ajax
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Referer: http://cloudflow-backend-local.arctur.net:8080/index.jsf
Content-Length: 498
Cookie: lng=sl; ****************.*******
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
simonC
  • 4,101
  • 10
  • 50
  • 78
  • So, HTTP session isn't maintained? – BalusC Sep 07 '15 at 18:13
  • if I use f:ajax instead of p:ajax the @PostConstruct method is not invoked and also the listener is invoked, but I would like to know why? Is this a bug in primefaces p:ajax? – simonC Sep 07 '15 at 19:27
  • So, you're manually including jQuery? Did you check the browser's console for clues as instructed in http://stackoverflow.com/tags/jsf/info? – BalusC Sep 07 '15 at 19:28
  • @BalusC I have updated the question, the broswer console has no errors, I have also included the request headers data in the questioin when called from p:ajax or f:ajax – simonC Sep 08 '15 at 09:18
  • Not sure if this will help, but I'd say the `p:ajax` should use `update="@(form)"` instead of `update="@form"` (note the parenthesis). – Sva.Mu Sep 10 '15 at 19:28

1 Answers1

0

Is your managed bean really annotated as ViewScope? You only show the import but not the annotation, in that case, if no scope annotation is found, your managed bean is Request Scope.

malaguna
  • 4,183
  • 1
  • 17
  • 33
  • yes my bean is annotated with javax.faces.view.ViewScoped and is a CDI bean not a managed bean, I have also find out that if I use f:ajax instead of p:ajax it works ok...is this a bug in prime faces? – simonC Sep 07 '15 at 17:30
  • 3
    This should be a comment not an answer. – Ced Sep 07 '15 at 18:44