【问题标题】:Composite Component with wrong backing object具有错误支持对象的复合组件
【发布时间】:2015-11-05 16:51:25
【问题描述】:

我有两个复杂的复合组件,它们呈现在页面的不同部分。它们每个都有自己的支持 bean,它们扩展 UIInput 以便根据组件输入将转换后的值提交回服务器。这些组件单独工作正常,并根据需要更新和提交它们的值。但是,当它们放在同一页面上时,尽管没有明显的联系(除了在同一页面上),它们似乎相互冲突。

其中一个组件位于页面的主要部分,另一个位于 p:dialog 中。当我执行更新对话框或其内容的 ajax 请求时,请求失败。

Firefox 报告控制台警告:“XML 或文本声明不在实体开头”

从服务器返回的响应看起来像是两个相互混合的独立部分响应。它在它们的第一个结束标记之前有两个 标记,它也有两个 标记。它们不是一个接一个,在第二个 xml 和部分响应标记之前您会期望通常的更新,然后第二组之后的数据是来自服务器的错误。

在服务器端,服务器报告在渲染视图时出现错误,并且在尝试渲染 ComponentA.xhtml(不是来自 ajax 请求的更新的一部分)时,属性“Extras”(这是一个属性)在 ComponentA 的数据中没有找到 Component B(它是更新的一部分)作为值的对象。

所以看起来页面正在尝试重新渲染或以其他方式处理组件 A,即使它应该从 ajax 请求中排除,然后将其提供给作为 ajax 请求一部分的组件 B 的数据.我已经检查以确保组件的 id 不同,它们指向正确的支持 bean,并且这些 bean 指向正确的组件并且它仍然无法正常工作。在这一点上,我被困住了。有人有什么想法吗?

编辑

在回答 BalusC 的问题时,服务器或应用程序中没有设置特殊的异常处理。无论 Mojarra 2.1.3 的默认设置是什么,我们都在使用 Primefaces 5.0 和 Tomcat 7。这是tomcat服务器输出的唯一异常:

Nov 5, 2015 11:40:27 AM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SEVERE: Error Rendering View[/program/toc/tocmain.xhtml]
javax.el.PropertyNotFoundException: /resources/ppa/personselector.xhtml @55,136 rendered="#{not empty item.extras}": Property 'extras' not found on type org.ppa.pejsf.objects.FreeFormDrugData
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
    at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:413)
    at javax.faces.component.UIComponent.isVisitable(UIComponent.java:1646)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1579)
    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 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 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 org.primefaces.component.api.UITabPanel.visitTree(UITabPanel.java:916)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
    at javax.faces.component.UIForm.visitTree(UIForm.java:344)
    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.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:376)
    at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:297)
    at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)
    at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:981)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:390)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
    at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:701)

编辑 2

如果它有帮助,看起来问题出现在渲染视图时,并且组件 B 的值在后端不为空。

【问题讨论】:

  • 按要求添加异常
  • 它声称尝试呈现的组件不是进程或更新中 ajax 请求的一部分,并且它尝试访问的对象甚至不是分配给组件的对象如果它是。为了让事情更清楚,我的组件 A 的值为 A,组件 B 的值为 B。B 包含在 ajax 请求中,但错误是它无法呈现组件 A,因为值 B 没有权限属性。

标签: ajax jsf composite-component


【解决方案1】:

嗯,我从来没有找到发生这种情况的原因,但我确实找到了防止它发生的解决方案。如果我在 ajax 请求的渲染/更新列表中包含系统尝试渲染(但不应该)的组件,问题就会消失。

【讨论】:

    猜你喜欢
    • 2011-07-23
    • 2018-05-11
    • 2012-04-29
    • 1970-01-01
    • 2017-09-07
    • 2018-10-12
    • 2016-07-01
    • 1970-01-01
    • 2013-08-22
    相关资源
    最近更新 更多