spring-projects / spring-session

Spring Session
https://spring.io/projects/spring-session
Apache License 2.0
1.86k stars 1.12k forks source link

Cant execute actions with dynamically rendered buttons - Primefaces, JSF and Spring Session #753

Closed joaocarlos86 closed 4 years ago

joaocarlos86 commented 7 years ago

Versions:

Primefaces 6.0 JSF (myfaces) 2.3 spring-session 1.3.0.RELEASE spring-session-data-redis 1.3.0.RELEASE lettuce 3.5.0.FINAL

I'm having issues using the HttpSession (SpringSession - redis) to clusterize the session of my users. The issue behavior is very specific, but, to me, looks like the ViewState is not being recovered correctly.

In a page I have a button (primefaces, ajax), when I click this button it triggers a action in my managed bean and a dialog is show with a text derived by the action executed in my managed bean. But, if I have a button that is dynamically rendered, when a action renders this button, the button doesn't trigger any action in my managed bean.

After debugging the execution stack of JSF, I've seen that the dynamically generated button action triggers the JSF lifecycle, but the action never reaches the ManagedBean.

Everything works fine if I remove spring session.

I'm providing a sample application proving the issue. (at https://github.com/joaocarlos86/spring-session-problem)

joaocarlos86 commented 7 years ago

The problem still occur if I switch my components from p:commandButton to h:commandButton and f:ajax, so, this is not related to primefaces. I've tried 2 JSF implementations: mojara and myfaces, so, it looks like not being a JSF related issue...

MarceloNunesAlves commented 6 years ago

@joaocarlos86, were you able to solve this problem?

dvtoever commented 4 years ago

I encounter similar problems using primefaces 6.2 The <p:ajax event="rowSelect" listener="#{controller.handleEvent} does invoke the event handleEvent(SelectEvent event) method, however event.getObject() is null. The issue is resolved if disable the springSessionRepositoryFilter in web.xml

Any idea why this filter breaks the primefaces ajax calls?

rwinch commented 4 years ago

Can someone put together a complete and minimal sample of the problem you are encountering?

dvtoever commented 4 years ago

It looks like the primefaces application is behaving a bit different because the HttpServletRequest is now inside SessionRepositoryRequestWrapper. For some reason it now triggers the APPLY_REQUEST_VALUES phase. This causes my LazyDataModel to load again also invoking getRowData(String rowId).

My LazyDataModel implementation was using an instance field holding all the entries. The getRowData method was looping through these entries. Somehow the instancefield was null during the apply request values phase. I refactored the implementation so the getRowData is now directly invoking a repository to fetch the required entry. This fixes the problem for me.

I hope it will be of use if anyone has a similar issue

rwinch commented 4 years ago

Thanks for the response @dvtoever. I'll leave this open to give others a chance to produce a minimal sample.

spring-projects-issues commented 4 years ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues commented 4 years ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.