流范围导航到起始页不起作用 [英] Flow scope navigation to start page does not work

查看:109
本文介绍了流范围导航到起始页不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不是一个问题,更多的是注释. 借助Glassfish4,我尝试在JEE7应用程序中通过程序化流程定义(用@Produces @FlowDefinition注释的Java类)使用流程范围.

It is not so much a question, more of a note. With Glassfish4, in a JEE7 application I tried to use the flow scope using programmatic flow definition (java class annotated with @Produces @FlowDefinition).

我使用ah:commandButton导航到流程的开始页面(就像在JEE7教程示例

I navigated to the start page of the flow with a h:commandButton (just as it is done in the JEE7 tutorial example https://svn.java.net/svn/javaeetutorial~svn/trunk/examples/web/jsf/checkout-module. When I pressed the button it stayed on the same page, where the button was, instead of going to the flow's start page.

经过许多小时的痛苦,我意识到问题出在bean.xml中,在我的beans.xml中我有这个问题:

After many hours of suffering, I realized that the problem is in the beans.xml, in my beans.xml I had this:

bean-discovery-mode="annotated"

这是根据文档建议的设置( http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/beans_1_1.xsd ). 当我将其更改为

which is the recommended setting according to the documentation (http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/beans_1_1.xsd). When I changed this to

bean-discovery-mode="all"

它开始工作.

以某种方式,CDI无法将流定义识别为带注释的类.我试图将其设置为@Named类或@ApplicationScoped类,但这些方法都不起作用. 我不知道这是否是预期的行为或错误.

Somehow CDI does not recognize the flow definition as an annotated class. I tried to make it a @Named class, or a @ApplicationScoped class, but non of these helped. I don't know if it is the intended behavior, or a bug.

希望它可以将我们的文件保存给某人.

Hope it saves a few ours to someone.

推荐答案

这与CDI检测bean档案的方式有关.当bean-discovery-mode="annotated"时,仅使用 bean定义注释由CDI提取;请注意,@Named@FlowScoped不在该列表中.

This is related to how CDI detects bean archives. When bean-discovery-mode="annotated", only classes annotated with bean defining annotations are picked up by CDI; note that @Named and @FlowScoped aren't on that list.

因此,如您在此处所述,使用Flow批注需要设置bean-discovery-mode="all".

Because of this, as you've documented here, using Flow annotations requires bean-discovery-mode="all" to be set.

有一个规范问题正在讨论这是否是理想的行为.

There's a spec issue open to discuss if this is a desired behavior.

这篇关于流范围导航到起始页不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆