JSF 2.0 导航不工作

发布于 2024-12-07 08:24:59 字数 880 浏览 0 评论 0原文

我正在使用 Netbeans 7.0、Glassfish 3.1、JSF 2.0 我正在尝试通过逐步的用户注册过程(分三个步骤)从一个视图导航到另一个视图。每个步骤对应一个视图,这些视图位于不同的文件夹中,但具有相同的名称,即register.xhtml。我尝试过隐式导航,在托管 bean 事件侦听器中指定视图的绝对路径,并使用 faces-config.xml 导航案例。

问题是我可以毫无问题地从第一步/视图导航到下一步/视图。然而,导航到第三个视图会导致 com.sun.faces.context.FacesFileNotFoundException

文件结构类似于

/extensions/assm/registration/individual/register.xhtml
/extensions/assm/registration/address/register.xhtml
/extensions/assm/registration/systemuser/register.xhtml

faces-config.xml 的提取,用于从地址导航到系统用户

<navigation-rule>
<from-view-id></from-view-id>
<navigation-case>
<from-outcome>gotosystemuser</from-outcome>
<to-view-id>/extensions/aasm/registration/systemuser/register.xhtml</to-view-id>
</navigation-case>
</navigation-rule>

有人知道我哪里出错了吗?

I am using Netbeans 7.0, Glassfish 3.1, JSF 2.0
I am trying to navigate from one view to another in a step-wise user registration process (with three steps). Each step corresponds to a view and these views are in different folders but all have the same name, i.e register.xhtml. i have tried implicit navigation whereby i specify the absolute path of the views in a managed bean event listener and also using the faces-config.xml navigation cases.

The problem is that i can navigate from the first step/view to the next step/view without a problem. Navigating to the third view however results in a com.sun.faces.context.FacesFileNotFoundException

the file structure is like

/extensions/assm/registration/individual/register.xhtml
/extensions/assm/registration/address/register.xhtml
/extensions/assm/registration/systemuser/register.xhtml

extract of faces-config.xml for navigating from address to systemuser

<navigation-rule>
<from-view-id></from-view-id>
<navigation-case>
<from-outcome>gotosystemuser</from-outcome>
<to-view-id>/extensions/aasm/registration/systemuser/register.xhtml</to-view-id>
</navigation-case>
</navigation-rule>

anyone out there know where i am getting it wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

氛圍 2024-12-14 08:24:59

com.sun.faces.context.FacesFileNotFoundException

表示 JSF 无法找到该视图。您在 navigation-rule 中指定的 view id 不太好(不知何故)。

视图由包含上下文根之后的所有内容的路径来标识,包括开头的/

但您还必须在 web.xml 中包含使用 Faces Servlet 映射的 URL 模式
例如,如果您的 web.xml 中有的话

<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/jsf/*</url-pattern>

,那么您还必须将其包含为View ID。所以,视图 id 将是

/jsf/folder1/folder2/page.xhtml

但使用 JSF 2.0,您不需要在 faces-config 文件中执行所有导航规则。
在 JSF 2.0 中,要导航到另一个页面,您所需要做的就是从操作方法返回视图 id。

@ManagedBean
@ViewScoped
public class MyBean {

    public String axnMethod() {
        return "view-id"; //this will result in navigation to view represented by view-id
    }

com.sun.faces.context.FacesFileNotFoundException

means that JSF is not able to locate the view. The view id you have specified in the navigation-rule is not good (somehow).

A view is identified by the path with everything after the context root, including the / at the beginning.

But you also have to include the URL pattern that's mapped with the Faces Servlet in web.xml.
e.g. if in your web.xml if you have

<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/jsf/*</url-pattern>

then you have to also include that as the View ID. So, with the view id will be

/jsf/folder1/folder2/page.xhtml

But with JSF 2.0 you don't need to do all that navigation-rule in the faces-config file.
In JSF 2.0 to navigate to another page all you need to do is return the view id from the action method.

@ManagedBean
@ViewScoped
public class MyBean {

    public String axnMethod() {
        return "view-id"; //this will result in navigation to view represented by view-id
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文