h:outputScript导致Primefaces页面中的IndexOutOfBoundsException

时间:2014-06-12 09:12:09

标签: primefaces indexoutofboundsexception

我在我的项目中使用Primefaces 4.0。 当我在模板文件中使用h:outputScript时,获取javax.faces.FacesException:为id为j_idt54的组件恢复状态时出现意外错误。原因:java.lang.IndexOutOfBoundsException:。

从模板中删除outputScipt标记,每个方面都可以。

<h:outputScript library="script"  name="/resources/script/generalScript.js"></h:outputScript>       

</h:body>

<p:commandButton value="Login" action="#{view.login}"
                styleClass="user-buttonLvl2" >
            </p:commandButton>

printStackTrace就是:

javax.faces.FacesException: Unexpected error restoring state for component with id j_idt54.  Cause: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0.
at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:273)
at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1589)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at com.sun.faces.component.visit.VisitUtils.doFullNonIteratingVisit(VisitUtils.java:75)
at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:257)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:181)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:448)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:303)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:187)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:111)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)

非常感谢您的回答。

1 个答案:

答案 0 :(得分:0)

如果您使用的是 library =“script”标记,请在名称标记中提供script文件夹中的路径。

像这样: name =“generalScript.js”

名称标签本身添加了脚本的完整路径。