0

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?
prageeth
  • 7,159
  • 7
  • 44
  • 72

1 Answers1

1

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

Community
  • 1
  • 1
Karl Kildén
  • 2,415
  • 22
  • 34
  • IMO FlowScoped is over-engineered for most use-cases and CODI scopes are better. I hope DeltaSpike will have them as well. – Dar Whi Nov 16 '13 at 23:25
  • @DarWhi I might agree I have to use it a little more first. Deltaspike will have them, it's coming in a overhauled version that's been stopping the import thus far because of time restraints for key committers. – Karl Kildén Nov 17 '13 at 20:12
  • The SO link you provided seems interesting. Thanks. – prageeth Nov 18 '13 at 09:02