Using JSF 2.0 / Facelets, is there a way to attach a global listener to all AJAX calls?

后端 未结 2 459
情深已故
情深已故 2020-11-30 09:21

Is there a way to attach a global listener to all AJAX calls in JSF? Maybe through a phase listener or something?

Here is the conundrum... Lets say you\'re using f:a

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 10:03

    To redirect a jsf ajax request you need xml as follows

       
      
            
            
    
    

    Here XXX is url you want redirect to happen.

    On ajax call redirect sent is not as above hence no redirect.

    To get the desired result have a filter for all jsf request except few pages(login page) and check session is valid and if it is really jsf ajax call by checking header "Faces-Request", its value should be "partial/ajax". If session has expired and is ajax request send above xml as response.

    It should work.

提交回复
热议问题