MyFaces: all pages throw duplicate id error after enabled partial state saving
In a JSF 2.2 project with PrimeFaces (currently latest: 5.1) I have had problems with <p:fileUpload>
. In a multi upload scenario randomly selected files were not uploaded. The problem was finally solved by enabled Partial State Saving (PSS) in web.xml:
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>true</param-value>
</context-param>
Now after enabling PSS, almost all my pages throw duplicate id exception (although there is really no duplicate0. I have CRUD pages with <p:dataTable>
and binding to view-scoped beans. When I switch to Mojarra duplicate id errors are gone, but for some reasons I want to work with MyFaces. Is there any workaround? Is this a bug with MyFaces.
I'm using MyFaces 2.2.5. And here is the related part of stack trace (at line 90, I have the first <p:column>
inside a <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/58688.html