JSF 2.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
com.sun.faces.context.FacesFileNotFoundException
表示 JSF 无法找到该视图。您在
navigation-rule
中指定的view id
不太好(不知何故)。视图由包含
上下文根
之后的所有内容的路径来标识,包括开头的/
。但您还必须在
web.xml
中包含使用Faces Servlet
映射的URL 模式
。例如,如果您的 web.xml 中有的话
,那么您还必须将其包含为
View ID
。所以,视图 id 将是但使用 JSF 2.0,您不需要在
faces-config
文件中执行所有导航规则。在 JSF 2.0 中,要导航到另一个页面,您所需要做的就是从操作方法返回视图 id。
com.sun.faces.context.FacesFileNotFoundException
means that JSF is not able to locate the view. The
view id
you have specified in thenavigation-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 theFaces Servlet
inweb.xml
.e.g. if in your web.xml if you have
then you have to also include that as the
View ID
. So, with the view id will beBut 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.