在使用PrimeFaces的JSF 2.2项目中(目前最新版本:5.1)我遇到了<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异常(尽管实际上没有重复的0。我有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]
答案 0 :(得分:2)
仅供参考,JSF规范3.1.5组件绑定说:“......如果应用程序开发人员将组件绑定表达式指向的托管bean放在请求范围以外的任何范围内,则系统无法正常运行。 ......在“会话”或“视图”范围内放置组件绑定时,对内存管理也有潜在的负面影响....“