Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CDI/Weld - how to handle browser page refresh after ending conversation?

In the very early days of using CDI I'm navigating to a page with a long running conversation active using faces-redirect=true, so I have a URL like ..myPage.xhtml?cid=1.

At some point I end the conversation, I mean this has to be a reasonable thing to do or you might as well use session scope? Anyway, I end the conversation and then the user hits F5, and then of course this causes a 'conversation not found' error as cid=1 doesn't exist.

Can anyone suggest how to get around this problem? I'm using the Steven Verborgh ViewScoped implementation and simply using a conversation scoped bean to pass parameters between pages. So I have for example 2 @ViewScoped beans each of which back page 1 & 2. I @Inject the @ConversationScoped ParameterBean into both view scoped beans. I start the conversation (parameterBean.getConversation().begin()) in the action method called from page 1. In the preRenderView event for page 2 I take a reference to the properties of the parameterBean into a page 2 backing bean instance variable and end the conversation, it's done it's job and no longer required.

Except for the F5 problem it works fine. If anyone has any suggestions I'd appreciate it, hopefully I'm not missing something really obvious. I kind of assuming there's no getting away from a redirect.

Thanks.

like image 274
Oversteer Avatar asked Oct 10 '22 17:10

Oversteer


1 Answers

There is no workaround for it. The default @ConversationScoped is utterly broken. I'm using the @ConversationScoped from MyFaces CODI instead. It solves all problems you can get with the standard scope.

like image 175
Dar Whi Avatar answered Jan 03 '23 09:01

Dar Whi