MyFaces:启用部分状态保存后,所有页面都会出现重复的id错误
在PrimeFaces(当前最新的:5.1)的JSF 2.2项目中,我遇到了<p:fileUpload>
。 在多上传方案中,未上传随机选择的文件。 问题终于通过在web.xml中启用部分状态保存(PSS)来解决:
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>true</param-value>
</context-param>
现在,在启用PSS后,几乎所有的页面都会抛出重复的id异常(虽然实际上没有duplicate0,我的CRUD页面中包含<p:dataTable>
并绑定到视图范围的bean)当我切换到Mojarra时,重复的id错误消失了,但出于某些原因,我想使用MyFaces。是否有任何解决方法?这是MyFaces的一个错误。
我使用MyFaces 2.2.5。 这里是堆栈跟踪的相关部分(在第90行,我有第一个<p:column>
在一个<p:dataTable>
):
2014-11-01 11:31:51,390 ERROR <admin> Unhandled exception on component null during phase RENDER_RESPONSE(6):
org.apache.myfaces.view.facelets.compiler.DuplicateIdException: Component with duplicate id "form:keywordDataTable:j_id_39" found. The first component is /admin/keyword.xhtml at line 90 and column 99
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.createAndQueueException(CheckDuplicateIdFaceletUtils.java:152) ~[myfaces-impl-2.2.5.jar:2.2.5]
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletUtils.java:107) ~[myfaces-impl-2.2.5.jar:2.2.5]
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletUtils.java:124) ~[myfaces-impl-2.2.5.jar:2.2.5]
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletUtils.java:124) ~[myfaces-impl-2.2.5.jar:2.2.5]
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletUtils.java:124) ~[myfaces-impl-2.2.5.jar:2.2.5]
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletUtils.java:124) ~[myfaces-impl-2.2.5.jar:2.2.5]
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletUtils.java:89) ~[myfaces-impl-2.2.5.jar:2.2.5]
at org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.saveView(DefaultFaceletsStateManagementStrategy.java:688) ~[myfaces-impl-2.2.5.jar:2.2.5]
at org.apache.myfaces.application.StateManagerImpl.saveView(StateManagerImpl.java:213) ~[myfaces-impl-2.2.5.jar:2.2.5]
at javax.faces.application.StateManager.getViewState(StateManager.java:262) ~[myfaces-api-2.2.5.jar:2.2.5]
at org.apache.myfaces.context.servlet.PartialViewContextImpl.processPartialRendering(PartialViewContextImpl.java:581) ~[myfaces-impl-2.2.5.jar:2.2.5]
at org.apache.myfaces.context.servlet.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:415) ~[myfaces-impl-2.2.5.jar:2.2.5]
at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60) ~[primefaces-5.1.1-UR.jar:5.1.1-UR]
at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:85) ~[myfaces-api-2.2.5.jar:2.2.5]
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:516) ~[myfaces-api-2.2.5.jar:2.2.5]
at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541) ~[myfaces-api-2.2.5.jar:2.2.5]
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1891) ~[myfaces-impl-2.2.5.jar:2.2.5]
at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:313) ~[myfaces-impl-2.2.5.jar:2.2.5]
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:58) ~[myfaces-api-2.2.5.jar:2.2.5]
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:116) ~[myfaces-impl-2.2.5.jar:2.2.5]
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:267) ~[myfaces-impl-2.2.5.jar:2.2.5]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:200) [myfaces-api-2.2.5.jar:2.2.5]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) [catalina.jar:7.0.47]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.47]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) [tomcat7-websocket.jar:7.0.47]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) [catalina.jar:7.0.47]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.47]
仅供参考,JSF规范第3.1.5节的组件绑定说:“...如果应用程序开发人员将组件绑定表达式指向的任何作用域指向的受管Bean放在请求范围以外的任何作用域中,则系统无法正常工作....在“会话”或“查看”范围中放置组件绑定时,也会对内存管理产生潜在的负面影响......“
链接地址: http://www.djcxy.com/p/58687.html上一篇: MyFaces: all pages throw duplicate id error after enabled partial state saving