ViewExpiredException is thrown when an unload is made with F5 from an input #259

Closed
cipriandobra opened this Issue Jun 2, 2016 · 10 comments

Projects

None yet

2 participants

@cipriandobra

Environment: Glassfish 4.1.1, JSF 2.2.12, Omnifaces 2.3, Primefaces 5.3

The next are needed to reproduce the problem:

  • a page with an input that has an AJAX handler for keyup event.
  • a backing bean with @org.omnifaces.cdi.ViewScoped annotation

When F5 is pressed the unload event is posted to the server which unloads the view and removes it from JSF view state map.
Immediately after the unload event a keyup event is posted to the server, but it does not find the view anymore and a ViewExpiredException is thrown.

@BalusC
Member
BalusC commented Jun 3, 2016

Can't reproduce on Payara 4.1.1.161 (Mojarra 2.2.12), WildFly 10.0.0 (Mojarra 2.3.0-m05) nor Tomcat 8.0.35 (Mojarra 2.2.13).

Can you reproduce this on other servers too? Which webbrowser were you using?

@cipriandobra

I did not try with other servers.
The browser where this happens is Firefox 46.0.1.

On Chrome 50.0.2661.102 only one POST is sent (the one for unload). The POST corresponding to the keyup (for F5) is not sent.

Firefox after F5:
firefox-f5 refresh

Chrome after F5:
chrome-f5 refresh

@BalusC
Member
BalusC commented Jun 3, 2016 edited

Couldn't reproduce in Firefox 42. I couldn't update it to 46 as it's prepackaged with Linux Mint and no newer package was available. Which OS are you using?

@cipriandobra

I'm using Windows 8.1

I did not say explicitly that the input that has the <p:ajax event="keyup" delay="500" .../> has focus at the moment F5 key is pressed.

@BalusC
Member
BalusC commented Jun 3, 2016 edited

I initially used <f:ajax> without delay. Still can't reproduce it when using delay and/or <p:ajax>. The field had focus all the time. When adding delay, I tried F5ing before and after the trigger. Both cases still work fine in both Firefox 42 and Chrome 47 (on Linux Mint 17.2 Rafaela). Will try Windows this weekend.

@cipriandobra

Do you have only the POST for the unload followed by the GET's or two POST's like in my screenshot of Firefox from above?

@BalusC
Member
BalusC commented Jun 3, 2016 edited

Only the unload (as expected). The keyup didn't trigger any POST on F5 (and therefore I never succeed to reproduce your problem).

@cipriandobra
cipriandobra commented Jun 3, 2016 edited

I rechecked my configuration and I think the problem is related to how I pass control from the login page (index.xhtml) to the main page (MainPage.xhtml): I have a navigation rule with a navigation-case that did not have <redirect>true</redirect>.
After the login the shown URL ends in "index.xhtml". The POST's are correctly sent to view "MainPage.xhtml". On F5, the unload event is sent to the view "index.xhtml". As far as I see this is the reason that both events are sent.
Since I have added <redirect>true</redirect> to the navigation-case and "MainPage.xhtml" is used also for unload, the keyup event is no longer sent. I can't estimate at this moment, but this way I might have solved another possible problems.

As a conclusion I'd say that my bad configuration created the problem with one note: maybe the unload event could post to the same view as the one used by ajax calls?

@BalusC BalusC closed this in d1a6527 Jun 3, 2016
@BalusC
Member
BalusC commented Jun 3, 2016

I can see the problem now. I have fixed it to not anymore assume window.location as unload target but instead JSF form action.

The fix is available in today's latest 2.4-SNAPSHOT. Can you give it a try and let me know if that indeed solves the problem for you.

@BalusC BalusC added a commit that referenced this issue Jun 3, 2016
@BalusC BalusC #259: fix return type in jsdoc 8911999
@cipriandobra

Thank you for your help.

I'll check the fix and let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment