JSF Flow - 隐式导航不起作用
Posted
技术标签:
【中文标题】JSF Flow - 隐式导航不起作用【英文标题】:JSF Flow - Implicit navigation doesn't work 【发布时间】:2016-11-04 16:15:44 【问题描述】:我开始使用 JSF Flow。我正在按照本教程http://courses.coreservlets.com/Course-Materials/pdf/jsf/jsf2/JSF-2.2-Faces-Flow-1.pdf,第 6-12 页中的说明进行操作。
隐式导航对我不起作用,就像在教程中一样。 当我导航到 index.xhtml,然后单击 commandButton 到 sampleFlow 时,我得到 nullPointerException。 点击刷新/F5 后,我的流页被加载。然后我可以使用 Page-A 和 Page-B 链接。 但是,每当我想导航出流程时,使用 index、sampleFlow-return,我都会得到相同的堆栈。
玻璃鱼日志
FATAL: JSF1073: javax.faces.FacesException caught during processing of INVOKE_APPLICATION 5 : UIComponent-ClientId=, Message=null
FATAL: No associated message
javax.faces.FacesException
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:89)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.Abstractiostrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at com.sun.faces.flow.FlowCDIContext.flowEntered(FlowCDIContext.java:423)
at com.sun.faces.flow.FlowHandlerImpl.pushFlow(FlowHandlerImpl.java:392)
at com.sun.faces.flow.FlowHandlerImpl.transition(FlowHandlerImpl.java:280)
at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:240)
at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:183)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:132)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
... 31 more
我创建了一个简单的应用程序,结构如下:
| index.xhtml
| sampleFlow-return.xhtml
|
+---sampleFlow
| page_a.xhtml
| page_b.xhtml
| sampleFlow-flow.xml
| sampleFlow.xhtml
|
\---WEB-INF
web.xml
每个 *.xhtml 页面都包含相同的 set commandButtons
<h:form>
<h:commandButton action="sampleFlow" value="sampleFlow"/><br/>
<h:commandButton action="page_a" value="sampleFlow - page A"/><br/>
<h:commandButton action="page_b" value="sampleFlow - page B"/><br/>
<h:commandButton action="sampleFlow-return" value="sampleFlow - return"/><br/>
<h:commandButton action="index" value="Home"/><br/>
</h:form>
我的 sampleFlow-flow.xml 是空的,如教程所述。
我正在使用 Glassfish 4.1.1 运行 Netbeans 8.1
【问题讨论】:
【参考方案1】:我不见了
\---WEB-INF
beans.xml
这个文件基本上可以是空的,只有开始和结束标签。 示例 xml 可能如下所示
<?xml version="1.0" encoding="UTF-8"?>
<beans version="1.2" bean-discovery-mode="all"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_2.xsd">
</beans>
添加此虚拟文件后,导航按预期工作。
【讨论】:
以上是关于JSF Flow - 隐式导航不起作用的主要内容,如果未能解决你的问题,请参考以下文章