gpt4 book ai didi

java - JSF Composite 组件仅在一页中运行

转载 作者:太空宇宙 更新时间:2023-11-04 08:24:46 26 4
gpt4 key购买 nike

我遇到了一个奇怪的问题。我创建了一个带有方法签名的简单复合组件:

<c:interface>
<c:attribute name="valorBusca" default="" required="true" type="java.lang.String"/>
<c:attribute name="listenerBusca" required="true" method-signature="void buscarAlgo(javax.faces.event.AjaxBehaviorEvent)"/>
<c:facet name="filtrosAdicionais"/>
<c:facet name="tabela"/>
<c:facet name="informacoes"/>
</c:interface>

<c:implementation>
<h:outputStylesheet library="css" name="clearfix.css" target="head"/>
<h:outputStylesheet library="css" name="camposFormulario.css" target="head"/>
<h:outputStylesheet library="css" name="listagem.css" target="head"/>
<h:panelGroup layout="block" styleClass="hrgi-div-form tamanho-aba-cadastro clearfix">
<p:fieldset legend="Filtro" styleClass="clearfix" style="width: 94.5%">
<h:panelGroup layout="block" styleClass="clearfix">
<h:outputLabel value="Buscar:"
title="Insira a informação a ser buscada."
styleClass="hrgi-label-form hrgi-listagem-label" style="padding-right: 8px;"/>
<p:inputText value="#{cc.attrs.valorBusca}"
autocomplete="off" immediate="true" style="width:90%"
title="Insira a informação a ser buscada.">
<f:ajax event="keyup" render="tabelaListagem" execute="@this"
immediate="true" listener="#{cc.attrs.listenerBusca}"/>
</p:inputText>
</h:panelGroup>
<c:renderFacet name="filtrosAdicionais" required="false"/>
</p:fieldset>
<h:panelGroup id="tabelaListagem" layout="block" class="clearfix"
style="width:99%; margin: 1em auto 0 auto;">
<c:renderFacet name="tabela" required="true"/>
</h:panelGroup>
<h:panelGroup id="painelInformacoes" layout="block" styleClass="clearfix">
<p:fieldset legend="Informações" style="width: 94.5%">
<c:renderFacet name="informacoes" required="true"/>
</p:fieldset>
</h:panelGroup>
</h:panelGroup>

它不起作用,所以我在 glassfish 3.1.1 中将 mojarra 更新到版本 2.1.4,但我不知道为什么,它在一个 xhtml 文件中工作,但在另一个 xhtml 文件中不起作用...

在这里它工作正常:

<ui:composition template="../templates/popup.xhtml">
<ui:param name="titulo"
value="#{vendaMsg['popup.adicionar_produto.titulo']}"/>
<ui:param name="popup" value="#{modeloPopupCarregarProduto}"/>
<ui:param name="controladorPopup"
value="#{controladorPopupCarregarProduto}"/>
<ui:define name="conteudo">
<h:panelGroup layout="block" styleClass="hrgi-div-form clearfix">
<hrgi:listagem listenerBusca="#{controladorPopupCarregarProduto.buscarProdutos}"
valorBusca="#{modeloPopupCarregarProduto.valorBusca}">

.............................

</hrgi:listagem>
</h:panelGroup>
</ui:define>
</ui:composition>

并且根本不起作用:

<ui:composition template="../templates/popup.xhtml">
<ui:param name="titulo" value="#{cadastroMsg['popup.cadastro.listagem_produto.titulo']}"/>
<ui:param name="popup" value="#{modeloPopupListagemProduto}"/>
<ui:param name="controladorPopup" value="#{controladorPopupListagemProduto}"/>
<ui:define name="conteudo">
<h:panelGroup layout="block" styleClass="hrgi-div-form clearfix">
<hrgi:listagem listenerBusca="#{controladorPopupListagemProduto.buscarProdutos}"
valorBusca="#{modeloPopupListagemProduto.valorBusca}">

.................................

</hrgi:listagem>
</h:panelGroup>
</ui:define>
</ui:composition>

在第二页中我收到此错误:

javax.el.PropertyNotFoundException: /resources/components/popups/modulo_cadastro/popupListagemProduto.xhtml @18,82 listenerBusca="#{controladorPopupListagemProduto.buscarProdutos}": The class 'com.hrgi.ui.controladores.popups.ControladorPopupListagemProduto' does not have the property 'buscarProdutos'.
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
at com.sun.faces.facelets.el.ContextualCompositeMethodExpression.invoke(ContextualCompositeMethodExpression.java:190)
at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:450)
at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:453)
at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113)
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:102)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:760)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:935)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at fr.xebia.servlet.filter.ExpiresFilter.doFilter(ExpiresFilter.java:1243)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)

另一个奇怪的事情是,在 Debug模式下它进入方法,当方法完成时抛出此错误!这是我尝试调用的方法(实际上与正确运行的其他方法相同):

public void buscarProdutos(AjaxBehaviorEvent evento) {
UIInput input = (UIInput) evento.getComponent();
String novoValor = (String) input.getValue();
carregarProdutos(novoValor);
}

我做错了一些我看不到的事情?

最佳答案

buscarProdutos() 方法实际上自己抛出了一个异常,但是由于 currently open bug (issue 1806)与调用复合组件中的操作相关,它会被吞没并作为 PropertyNotFoundException 重新抛出。

您可以在调试器中找到真正的异常和/或通过将方法主体放入try-catch并记录它。我敢打赌,是 carregarProdutos() 方法引发了异常。

关于java - JSF Composite 组件仅在一页中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8789113/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com