2012-04-26 50 views
2

我有一個奇怪的問題發生在我的web應用程序後,我改變了Mojarra MyFaces ... 我有一個xhtml文件,從外面加載,換句話說,這個xhtml被重用了很多:MyFaces是重複的身份證複製

<ui:composition template="../templates/popup.xhtml"> 
<ui:param name="titulo" value="#{modeloPopup.rotulo}"/> 
<ui:param name="popup" value="#{modeloPopup}"/> 
<ui:param name="controladorPopup" value="#{controladorPopup}"/> 
<ui:define name="conteudo"> 
    <h:panelGroup id="painelPopup" layout="block" styleClass="hrgi-div-form clearfix" style="width: 400px"> 
     <p:focus for="inputValor"/> 
     <h:panelGroup layout="block" styleClass="clearfix" style="margin-bottom: 5px;"> 
      <p:fieldset styleClass="fieldset-novo-registro" legend="#{msgGerais['gerais.novo_registro']}"> 
       <h:outputLabel for="inputValor" value="#{modeloPopup.tituloNome}" styleClass="hrgi-label-form"/> 
       <p:inputText id="inputValor" value="#{modeloPopup.elemento.valor}" maxlength="50" style="width: 210px"/> 
      </p:fieldset> 
      <p:commandButton value="#{msgGerais['gerais.adicionar']}" action="#{controladorPopup.adicionarValor}" 
          update="painelPopup alerta" style="margin-top: 10px;"/> 
     </h:panelGroup> 
     <h:panelGroup id="painelLista" binding="#{bindingPainel}" layout="block" styleClass="clearfix"> 
      <p:dataTable id="lista" var="bean" value="#{modeloPopup.lista}" scrollable="#{modeloPopup.lista.size()>5}" 
         height="145" rowEditListener="#{controladorPopup.editarValor}" onRowEditUpdate="alerta"> 
       <p:column headerText="Nome" sortBy="#{bean.valor}" style="width:80%"> 
        <p:cellEditor> 
         <f:facet name="output"> 
          <h:outputText value="#{bean.valor}"/> 
         </f:facet> 
         <f:facet name="input"> 
          <p:inputText value="#{bean.valor}"/> 
         </f:facet> 
        </p:cellEditor> 
       </p:column> 
       <p:column headerText="#{msgGerais['gerais.acoes']}" style="width:20%"> 
        <p:rowEditor/> 
        <p:commandLink action="#{controladorPopup.removerValor(bean)}" 
            style="text-align: center;margin: auto;" 
            update="#{bindingPainel.clientId} alerta confirmacao" immediate="true"> 
         <h:graphicImage library="img" name="remover.png"/> 
        </p:commandLink> 
       </p:column> 
      </p:dataTable> 
     </h:panelGroup> 
    </h:panelGroup> 
</ui:define> 
</ui:composition> 

這個XHTML是這樣使用:

<h:form id="cadastroRamoAtividade"> 
<ui:include src="resources/components/popups/modulo_cadastro/popupCadastroString.xhtml"> 
    <ui:param name="modeloPopup" value="#{modeloPopupCadastroRamoAtividade}"/> 
    <ui:param name="controladorPopup" value="#{controladorPopupCadastroRamoAtividade}"/> 
    <ui:param name="idPopup" value="popupNovoCadastroRamoAtividade"/> 
    <ui:param name="bindingPainel" value="#{painelListaRamoAtividade}"/> 
</ui:include> 
</h:form> 

我收到此錯誤:

[#|2012-04-26T10:25:14.527-0300|SEVERE|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=18;_ThreadName=Thread-2;|java.lang.IllegalStateException: component with duplicate id "cadastroRamoAtividade:popupNovoCadastroRamoAtividade:lista" found 
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIdsStatefulComponents(CheckDuplicateIdFaceletUtils.java:54) 
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIdsStatefulComponents(CheckDuplicateIdFaceletUtils.java:75) 
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIdsStatefulComponents(CheckDuplicateIdFaceletUtils.java:75) 
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIdsStatefulComponents(CheckDuplicateIdFaceletUtils.java:75) 
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIdsStatefulComponents(CheckDuplicateIdFaceletUtils.java:66) 
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIdsStatefulComponents(CheckDuplicateIdFaceletUtils.java:75) 
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIdsStatefulComponents(CheckDuplicateIdFaceletUtils.java:75) 
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIdsStatefulComponents(CheckDuplicateIdFaceletUtils.java:75) 
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIdsStatefulComponents(CheckDuplicateIdFaceletUtils.java:75) 
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIdsStatefulComponents(CheckDuplicateIdFaceletUtils.java:35) 
at org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.saveView(DefaultFaceletsStateManagementStrategy.java:489) 
at org.apache.myfaces.application.StateManagerImpl.saveView(StateManagerImpl.java:189) 
at javax.faces.application.StateManager.getViewState(StateManager.java:253) 
at org.apache.myfaces.context.servlet.PartialViewContextImpl.processPartialRendering(PartialViewContextImpl.java:550) 
at org.apache.myfaces.context.servlet.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:388) 
at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:88) 
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:402) 
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:755) 
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1900) 
at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:285) 
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:115) 
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241) 
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199) 
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:369) 
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:381) 
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97) 
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100) 
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78) 
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) 
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35) 
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177) 
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187) 
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) 
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79) 
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109) 
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:109) 
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:168) 
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(De|#] 
[#|2012-04-26T10:25:14.529-0300|SEVERE|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=18;_ThreadName=Thread-2;|faultProtocolChain.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) 

|#]

我已經在鉻瀏覽html源碼,並沒有發現任何重複的ID ... 有人知道我該如何解決它?

+0

我猜*這是''是這個問題的根源。嘗試刪除該「綁定」屬性並重試。 – BalusC 2012-04-26 14:38:12

+0

解決了,但現在我在我的所有f:ajax標記中使用了完整的id,導致[this](http://stackoverflow.com/questions/7666631/jsf-fajax-cannot-locate-component-on-context )。請@BalusC,爲我創建一個答案標記爲已解決... – brevleq 2012-04-27 14:34:38

回答

3

<h:panelGroup binding="#{bindingPainel}">是這個問題的根源。如果在同一視圖中有多個組件具有相同的binding,則會發生此異常。 binding屬性必須指向一個唯一的和基於請求的變量。

+0

對不起,我必須問.. *多個組件具有相同的綁定* 你引用panelGroup內的元素? (例如通過bindingPanel.getChildren.add(something)添加) – 2014-03-12 20:28:14