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

本小妞迷上赌 提交于 2019-12-06 03:11:13

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/6419442/cdi-weld-how-to-handle-browser-page-refresh-after-ending-conversation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!