My Project is using JSF2.0 and CDI. For one page, I want my backing bean to match the lifespan of the page. @ViewScoped seems a perfect fit but it's not part of CDI and then make our solution not consistent. Then my next option would be the CDI @ConversationScoped. Seems to me the only way to mark the boundary of a conversation is the program way via conversation.begin and conversation.end (I have used Seam 2.x, there you can use annotations to mark conversation boundary). My page is sitting in a common layout with global navigation, which means there are "unlimited" ways to leave my page. How can I make sure the conversation is ended whichever way the user might choose (e.g. clicking on a global navi option which is totally outside of my backing bean's control)? And I hope the solution would not spread the code to other modules; and if that's inevitable, I hope it could be implemented in a cross-cutting manner (AOP).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…