有没有人成功地将JSF 2 ViewScoped bean与Spring WebFlow 2集成在一起?

时间:2014-07-22 19:35:58

标签: jsf jsf-2 spring-webflow spring-webflow-2

我们使用@ManagedBean和@ViewScoped注释了JSF 2托管bean。然后在我们的Spring WebFlow flow.xml文件中;状态更改定义如on-start和on-entry开始抱怨它无法在任何范围内找到托管bean。

Jul 22, 2014 11:04:43 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jul 22, 2014 11:04:43 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 22, 2014 11:04:43 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 32586 ms
Jul 22, 2014 11:05:01 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [springMVCServlet] in context with path [/opp] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@1e4c320 targetAction = [EvaluateAction@1c6a657 expression = serviceProviderSubscriptionBB.loadServiceProviderSubscription(subscriptionHeaderId), resultExpression = [null]], attributes = map[[empty]]] in state 'null' of flow 'service-provider-subscription' -- action execution attributes were 'map[[empty]]'] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'serviceProviderSubscriptionBB' cannot be found on object of type 'org.springframework.webflow.engine.impl.RequestControlContextImpl' - maybe not public?
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:215)
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:85)
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:78)
    at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:48)
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:84)
    at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:114)
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:105)
    at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:84)
    at org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:75)
    at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
    at org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145)
    at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)
    at org.springframework.webflow.engine.ActionList.execute(ActionList.java:154)
    at org.springframework.webflow.engine.Flow.start(Flow.java:526)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:368)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:223)



<on-start>

    <evaluate
        expression="serviceProviderSubscriptionBB.loadServiceProviderSubscription(subscriptionHeaderId)" />

</on-start>

我们面临的另一个问题是;永远不会调用@ViewScoped bean上的销毁回调。我们在每个不同的JSF视图中获取新的bean实例,但是我们对它们中注入的旧bean和依赖bean没有任何线索。

有人可以帮忙吗?

感谢。

1 个答案:

答案 0 :(得分:1)

Flow文件只知道如何使用Spring Beans。

您可以使用@Component('serviceProviderSubscriptionBB')注释ManagedBean并让Spring处理它,或者您可以直接在流<var name="serviceProviderSubscriptionBB" class="the full name of your class"/>上声明托管bean,这样您的类就可以在整个流程中使用。

希望它有所帮助!