I am playing with JSF 2.2 (MyFaces implementation v2.2.6 and Weld v2.2.7.Final for CDI) since the beginning of the week and I'm facing the following problem : I can't directly access a flow entry point with my brother.
For example :
My webapp contains a flow named 'create' which permits to create a record in the database.
I would like to be able to enter the URL http://my.domain/webapp/create/create.jsf
in my browser address bar.
When I do so, the page doesn't correctly render and the following log appears in the server
log : WELD-001303 No active contexts for scope type javax.faces.flow.FlowScoped.
What am I doing wrong ? Shouldn't it be possible ? I hope it should !
I haven't any problem when I create a page, outside of the flow, having only one commandButton redirecting to the flow entry point. When I watch the source code, it seems that an id for the flow have already been created despite of the flow was not already accessed. That make me think FlowScoped is poorly designed. Moreover, such a work around (a 'launcher' page) breaks my own design and the end user experience.
What are the available solutions ?
Here is some sample code :
create.xhtml
<h1>Create record</h1>
<h:form id="create-record" prependId="false">
<label for="name">Name</label>
<h:inputText id="name" value="#{createController.name}" />
<h:commandButton title="Abandon" value="Abandon" id="abandon" action="returnFromCreate" immediate="true" />
<h:commandButton title="Validate" value="Validate" id="validate" action="#{createController.create()}" />
</h:form>
CreateController
package my.company;
import java.io.Serializable;
import javax.faces.flow.FlowScoped;
import javax.inject.Inject;
import javax.inject.Named;
@Named
@FlowScoped("create")
public class CreateController implements Serializable {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String create() {
// TODO
return "returnFromCreate";
}
}
xhtml "Launcher"
<h:form>
<h:commandButton action="create" value="Go" />
</h:form>
create-flow.xml only contains a "flow-return" directive.