问题
I´m trying to develop a simple example of new functionality of JSF 2.2, @FlowScope, I develop it with eclipse luna, glassfish 4.0, I guess the code is right cause I caught it on the web, probably the error is with the configuration of the project. Could anyone give me an Idea of what could be? Pleas ask me further information if it´s hard to understand with these few information but actually I don´t know what more I can write to help and this is my first question on stackoverflow.
public class NestedFlowBuilder implements Serializable {
private static final long serialVersionUID = 1L;
@Produces
@FlowDefinition
public Flow defineCallingFlow
(@FlowBuilderParameter FlowBuilder flowBuilder) {
String flowId = "secondJavaFlow";
flowBuilder.id("", flowId);
flowBuilder.viewNode(flowId, "/java-calling-flow/start-page.xhtml")
.markAsStartNode();
flowBuilder.viewNode("results",
"/java-calling-flow/results-page.xhtml");
flowBuilder.returnNode("return").fromOutcome("/return-page-for-java-calling-flow");
flowBuilder.returnNode("home").fromOutcome("/index");
flowBuilder.flowCallNode("go-to-nested")
.flowReference("", "thirdJavaFlow")
.outboundParameter("paramForNestedFlow",
"#{javaCallingFlowBean.param1}");
return(flowBuilder.getFlow());
}
@Produces
@FlowDefinition
public Flow defineNestedFlow
(@FlowBuilderParameter FlowBuilder flowBuilder) {
String flowId = "thirdJavaFlow";
flowBuilder.id("", flowId);
flowBuilder.viewNode(flowId,
"/java-nested-flow/start-page.xhtml")
.markAsStartNode();
flowBuilder.viewNode("results",
"/java-nested-flow/results-page.xhtml");
flowBuilder.returnNode("return-to-previous-start")
.fromOutcome("secondJavaFlow");
flowBuilder.returnNode("return-to-previous-results")
.fromOutcome("results");
flowBuilder.inboundParameter("paramForNestedFlow",
"#{javaNestedFlowBean.param3}");
return(flowBuilder.getFlow());
}
package coreservlets;
import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.flow.FlowScoped;
import javax.inject.Named;
@Named
@FlowScoped("thirdJavaFlow")
public class JavaNestedFlowBean implements Serializable {
private static final long serialVersionUID = 1L;
private String param3, param4;
public String doFlow() {
if (param3.equalsIgnoreCase(param4)) {
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage fMessage =
new FacesMessage("Params must be distinct");
fMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
context.addMessage(null, fMessage);
return(null);
} else {
return("results");
}
}
public String getParam3() {
return param3;
}
public void setParam3(String param3) {
this.param3 = param3;
}
public String getParam4() {
return param4;
}
public void setParam4(String param4) {
this.param4 = param4;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Java Calling Flow Start PAge</title>
</head>
<body>
<h:form>
<h:messages globalOnly="true" styleClass="error"/>
<h:panelGrid columns="3" styleClass="formTable">
Param 1:
<h:inputText value="#{javaCallingFlowBean.param1}" id="param1"
required="true"
requiredMessage="Param 1 is required"/>
<h:message for="param1" styleClass="error"/>
Param 2:
<h:inputText value="#{javaCallingFlowBean.param2}" id="param2"
required="true"
requiredMessage="Param 2 is required"/>
<h:message for="param2" styleClass="error"/>
<f:facet name="footer">
<h:commandButton value="Show Results"
action="#{javaCallingFlowBean.doFlow}"/><br/>
</f:facet>
</h:panelGrid>
</h:form>
</body>
</html>
I get this error:
javax.el.ELException: /java-calling-flow/start-page.xhtml @17,40 value="#{javaCallingFlowBean.param1}": org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.faces.flow.FlowScoped
http://courses.coreservlets.com/Course-Materials/pdf/jsf/jsf2/JSF-2.2-Faces-Flow-2.pdf from pag 33
来源:https://stackoverflow.com/questions/24868594/org-jboss-weld-context-contextnotactiveexception-weld-001303-no-active-contexts