I have a service, accessed by a servlet, which redirects the user to a login screen. The backing beans' scope is currently being changed from @ConversationScoped to @FlowScoped, as it's easier to handle.
Is there a way to initialize a faces flow directly from within a servlet, without the indirection through an implicit action or a JSF forward/redirect?
I am aware that @FlowScope is a JSF (2.2) scope and I was wondering if there might be a way to e.g. extend the FacesServlet or something similar.
As a workaround, I currently just added view with a button, which makes a JSF forward to enter the flow directory, but I am trying to avoid this.
Update
I tried many approaches to 'automatically' forward into a flow, without having to click on any button, but I always get a No active contexts for scope type javax.faces.flow.FlowScoped
. Here my approaches:
f:viewAction
<f:metadata> <f:viewAction action="myFlow" /> </f:metadata>
This one seems to be executed too early (in any case).
f:event
<f:event type="preRenderView" listener="#{myBean.forwardToMyFlow()}" />
The method in the bean returns the same outcome as in
f:viewAction
.Navigation case
<navigation-rule> <from-view-id>/myView.xhtml</from-view-id> <navigation-case> <from-outcome>myFlow</from-outcome> <to-view-id>/myFlow/myFlow.xhtml</to-view-id> <redirect /> <to-flow-document-id /> </navigation-case> </navigation-rule>
What am I missing?
@FlowScoped
beans must be initialized on entry to the first node in a flow – CharkhaContextNotActiveException
... – Geist