0

I have a situation where I have a multi-step wizard rendered using JSF 2.2, and deployed on Wildfly 10/JBoss EAP. Our wizard exists within a CDI Conversation to maintain state across all of the pages. Once the last step of the wizard completes, a record is saved to the database, and I call conversation.end() to end the workflow. I would like to display a value that exists within my Conversation scope to indicate to the user that the process has completed. However, when I end my Conversation, the value obviously goes away because it was set in Conversation scope.

Is there a way to tell CDI to end my Conversation after the final page has completed rendering? Is there a better way to handle the management of the Conversation?

Shadowman
  • 11,150
  • 19
  • 100
  • 198

1 Answers1

0

To my knowledge, there is no way to manipulate conversation scope as you would like to. Unless you could invoke conversation.end() after you redirect the user and display the value. But that would no longer fit into the wizard's lifecycle.

But a relatively simple way around that is using any broader scope that outlives the conversation and storing the value there. To stick with pure CDI, I'd go for @SessionScoped (after all, conversations live within session).

Shortly before you invoke conversation.end(), store the desired value into session scoped bean variable and display it from there.

Siliarus
  • 6,393
  • 1
  • 14
  • 30
  • I'd go for viewAccessScoped from Delta Spike... It is 'pure cdi' but an extension. Not a custom framework – Kukeltje Jul 17 '17 at 14:07
  • True, but you need to bring in DeltaSpike dependency to get that one. And a lot of people are against adding anything extra or are even forbidden to do so by project manag/lead. So I just tried to state the minimal way. – Siliarus Jul 18 '17 at 07:22
  • Sort or indeed happening a lot.... But... In my (sometimes not so) humble opinion, any project-lead that is against adding good existing **extensions** like Delta Spike or OmniFaces (or even PrimeFaces) and requires custom code to be written instead or using the relatively complex conversation constructs where a viewaccesscoped would be a great fit should be fired ;-) (I'm against explicit project leads or 'architects' anyway. The team should be the project lead and/or architect.) – Kukeltje Jul 18 '17 at 07:58