2012-08-03 212 views
1

有兩個類,A和B,其中B延伸的,它有一個屬性,它不存在於A.訪問子類屬性

在我的Managed Bean的,我養的一個實例,可以是否爲B型,取決於用戶在頁面上選擇的內容。

在我的xhtml頁面中,有時我需要做一些類似#{myBean.A.attribute}的操作,其中'attribute'僅存在於B類中。因此,試圖訪問此屬性的組件(或父代)必須具有類似rendered="#{myBean.isTypeBSelected()}"

它工作正常,出於某種原因,它開始拋出PropertyNotFoundException,因爲即使組件(或父級)正在評估呈現=「false」,它也試圖訪問該屬性。

完整堆棧跟蹤:

14:39:54,142 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--0.0.0.0-8080-3) /restrito/formularios/formularios.xhtml @340,63 value="#{formularioMB.perguntaSelecionada.opcoesResposta}": The class 'br.ind.seat.pso.modelo.PerguntaTexto' does not have the property 'opcoesResposta'.: javax.el.PropertyNotFoundException: /restrito/formularios/formularios.xhtml @340,63 value="#{formularioMB.perguntaSelecionada.opcoesResposta}": The class 'br.ind.seat.pso.modelo.PerguntaTexto' does not have the property 'opcoesResposta'. 
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111) [javax.faces-2.1.9.jar:2.1.9-SNAPSHOT] 
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIData.getValue(UIData.java:731) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at org.primefaces.component.datatable.DataTable.getValue(DataTable.java:773) [primefaces-3.3.1.jar:] 
at javax.faces.component.UIData.getDataModel(UIData.java:1798) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:484) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIData.setRowIndex(UIData.java:473) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIData.visitTree(UIData.java:1401) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIForm.visitTree(UIForm.java:371) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at org.omnifaces.eventlistener.ResetInputAjaxActionListener.resetEditableValueHolders(ResetInputAjaxActionListener.java:229) [omnifaces-1.1.jar:1.1] 
at org.omnifaces.eventlistener.ResetInputAjaxActionListener.access$000(ResetInputAjaxActionListener.java:107) [omnifaces-1.1.jar:1.1] 
at org.omnifaces.eventlistener.ResetInputAjaxActionListener$1.visit(ResetInputAjaxActionListener.java:241) [omnifaces-1.1.jar:1.1] 
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183) [javax.faces-2.1.9.jar:2.1.9-SNAPSHOT] 
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1612) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at org.omnifaces.eventlistener.ResetInputAjaxActionListener.resetEditableValueHolders(ResetInputAjaxActionListener.java:229) [omnifaces-1.1.jar:1.1] 
at org.omnifaces.eventlistener.ResetInputAjaxActionListener.processAction(ResetInputAjaxActionListener.java:174) [omnifaces-1.1.jar:1.1] 
at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [javax.faces-2.1.9.jar:2.1.9-SNAPSHOT] 
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [javax.faces-2.1.9.jar:2.1.9-SNAPSHOT] 
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [javax.faces-2.1.9.jar:2.1.9-SNAPSHOT] 
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:] 
at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31] 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:] 
at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65) [solder-impl-3.1.0.Final.jar:3.1.0.Final] 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:] 
at org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74) [solder-impl-3.1.0.Final.jar:3.1.0.Final] 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:] 
at br.ind.seat.pso.filtros.FiltroUrlPattern.doFilter(FiltroUrlPattern.java:44) [classes:] 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:] 
at br.ind.seat.pso.filtros.FiltroNoCache.doFilter(FiltroNoCache.java:46) [classes:] 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:] 
at br.ind.seat.pso.filtros.FiltroDePermissao.doFilter(FiltroDePermissao.java:45) [classes:] 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:] 
at br.ind.seat.pso.filtros.FiltroUsuarioLogado.doFilter(FiltroUsuarioLogado.java:44) [classes:] 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:] 
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final] 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:] 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:] 
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:] 
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:] 
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:] 
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_05] 
+1

將您的解決方案移至答案(是的,您可以回答您的問題)並[將其標記爲答案](http://meta.stackexchange.com/a/5235/182862)。如果您更改與問題相關的問題標題(從超類或類似方式訪問子資產)並從問題中刪除解決方案,那將會很好。 – 2012-08-04 18:40:36

+0

@LuiggiMendoza我做了你所說的,謝謝。 – RinaldoPJr 2012-08-09 11:03:55

回答

2

這是我用於添加<p: messages /><p:dialog />內部故障。 因此,即使我的對話框設置爲dynamic="true",它內部的<p: messages />也迫使它加載。

我通過在<p: messages/>中設置autoUpdate="false"來解決這個問題。