prageeth
prageeth

Reputation: 7415

CDI Conversation without ending

In my JSF project I have a multi page wizard. I am using a @ConversationScoped CDI bean for that wizard. The conversation works well. When user comes to the first page of the wizard, new conversation begins. When user clicks a submit button in any page, the conversation ends. But i have several questions.

  1. What happens if, at the middle of the wizard, the user entered a url in address bar and navigated to another page without clicking a submit button, do I still have a way to end the conversation?
  2. Should I bother about this situation or can accumulating such non-ended conversations become a overhead for my application?

Upvotes: 0

Views: 767

Answers (1)

Karl Kildén
Karl Kildén

Reputation: 2435

Most applications ends up with some kind of system that tracks where the user is currently at. This is supposed to be helped by @FlowScoped in JSF 2.2. If you can use that instead then everything should be managed for you. It should be really easy to find examples.

If you can't use FlowScoped and want to stay on @ConversationScoped you must implement your own system for tracking where the user is at. When the user is no longer in your flow you end the conversation.

 @Inject Conversation conversation;

// conversation.end();

Here is a useful part for implementing this: How to cleanly end a CDI @ConversationScoped

However I would go for http://deltaspike.apache.org/core.html and use: To get the conversation.

MyBean myBean = BeanProvider.getContextualReference(MyBean.class, false);

Personally I would do an extension to the type safe navigation in Deltaspikes JSF module to achieve the same thing if I could not use FlowScoped.

Good luck

Upvotes: 1

Related Questions