2012-04-03 109 views
5

不幸的是,primefaces如果你試圖動態地創建標籤accordionPanel沒有行之有效的2.2.1版本。這是我的情況,如果用戶點擊添加圖標,我需要創建手風琴,如果他點擊x圖標,請移除。沒問題,我已經創建了自己的複合成分,比如你可以在這裏看到:組件是裏面的UI相同的ID:重複

<c:interface> 
    <c:attribute name="titulo" default="" required="false" /> 
    <c:attribute name="renderizar" default="true" required="false" /> 
    <c:attribute name="width" required="false" default="300"/> 
    <c:facet name="extra" required="false" /> 
</c:interface> 

<c:implementation> 
    <h:outputStylesheet library="css" name="hrgiAccordion.css" target="head" /> 
    <h:outputStylesheet library="css" name="clearfix.css" target="head" /> 
    <h:outputScript library="js" name="hrgiAccordion.js" target="head" /> 
    <h:panelGroup layout="block" rendered="#{cc.attrs.renderizar}" 
    styleClass="hrgi-accordion clearfix" style="width: #{cc.attrs.width}px;"> 
     <div class="hrgi-cabecalho-accordion clearfix" 
      onclick="abrirAccordion(this)"> 
      <h:outputLabel value="#{cc.attrs.titulo}" /> 
      <c:renderFacet name="extra" required="false"/> 
     </div> 
     <h:panelGroup layout="block" class="hrgi-conteudo-accordion clearfix"> 
      <c:insertChildren /> 
     </h:panelGroup> 
    </h:panelGroup> 
</c:implementation> 

它工作正常,但我有一些細節需要...手風琴選項卡的內容是一些選擇和動態表與inputField和微調(又在我創建的),你可以看到用戶界面的位置:

Popup forma de pagamento

當紡紗用戶插入值,標籤「總DAS parcelas」應該更新,但它只是當對話框只有一個手風琴選項卡時更新!查看生成的html代碼我已經看到不同手風琴選項卡中的旋鈕是平等的!可能這是我無法更新值的原因。下面是該對話框的代碼:

<ui:composition template="../templates/popupSubmit.xhtml"> 
<ui:param name="titulo" value="#{vendaMsg['popup.forma_pagamento.titulo']}"/> 
<ui:param name="popup" value="#{modeloPopupFormaPagamento}"/> 
<ui:param name="controladorPopup" value="#{controladorPopupFormaPagamento}"/> 
<ui:define name="cabecalho"> 
    <h:panelGroup id="cabecalhoValores" binding="#{cabecalhoValores}" layout="block"> 
     <h:outputLabel value="#{vendaMsg['popup.forma_pagamento.total_prevenda']}" /> 
     <h:outputLabel value="#{preVendaBean.valorLiquido}"> 
      <f:convertNumber currencySymbol="R$" maxFractionDigits="2" 
          minFractionDigits="2" type="currency" currencyCode="BRL"/> 
     </h:outputLabel> 
     <hrgi:separador/> 
     <h:outputLabel value="#{vendaMsg['popup.forma_pagamento.total_parcelas']}" /> 
     <h:outputLabel value="#{controladorPopupFormaPagamento.calcularTotalParcelas()}"> 
      <f:convertNumber currencySymbol="R$" maxFractionDigits="2" 
          minFractionDigits="2" type="currency" currencyCode="BRL"/> 
     </h:outputLabel> 
    </h:panelGroup> 
</ui:define> 
<ui:define name="conteudo"> 
    <h:panelGroup layout="block" styleClass="clearfix hrgi-div-form"> 
     <h:panelGroup id="painelFormasDePagamento" binding="#{painelFormasDePagamento}" layout="block"> 
      <ui:repeat id="repeticao" var="formaPagamento" value="#{modeloPopupFormaPagamento.formasDePagamento}"> 
       <hrgi:accordion titulo="#{vendaMsg['popup.forma_pagamento.aba_acordeon.titulo']}" width="380"> 
        <f:facet name="extra"> 
         <p:commandLink action="#{controladorPopupFormaPagamento.removerForma(formaPagamento)}"           
             update=":#{painelFormasDePagamento.clientId}" global="false"> 
          <h:graphicImage library="img" name="remover.png"/> 
         </p:commandLink> 
        </f:facet> 
        <h:panelGroup layout="block" class="clearfix"> 
         <h:panelGroup id="painelSelecaoForma" layout="block"> 
          <h:outputLabel value="#{vendaMsg['popup.forma_pagamento.forma_pagamento']}"/> 
          <h:selectOneMenu value="#{formaPagamento.idFormaPagamento}"                 valueChangeListener="#{controladorPopupFormaPagamento.processarMudancaFormaPagamento}"> 
           <f:selectItems value="#{selectItemFormasPagamento.itens}"/> 
           <f:attribute value="#{formaPagamento}" name="formaPagamento"/> 
           <f:ajax event="change" render="painelSelecaoForma painelParcelasFormaPagamento" execute="painelSelecaoForma"/> 
          </h:selectOneMenu> 
          <h:outputLabel value="#{vendaMsg['popup.forma_pagamento.plano_pagamento']}"          /> 
          <h:selectOneMenu value="#{formaPagamento.idPlanoPagamento}"          valueChangeListener="#{controladorPopupFormaPagamento.processarMudancaPlanoPagamento}"> 
           <f:selectItems value="#{controladorPopupFormaPagamento.recuperarCarregador(formaPagamento).itens}"/> 
           <f:attribute value="#{formaPagamento}" name="formaPagamento"/> 
           <f:ajax event="change" render="painelParcelasFormaPagamento"/> 
          </h:selectOneMenu> 
         </h:panelGroup> 
         <h:panelGroup id="painelParcelasFormaPagamento" layout="block"> 
          <p:dataTable id="tabela" value="#{formaPagamento.parcelas}" var="parcela" 
             emptyMessage="#{msgGerais['gerais.sem_dados']}" 
             scrollable="#{formaPagamento.parcelas.size()>2}" 
             height="76"> 
           <p:column headerText="#{vendaMsg['popup.forma_pagamento.tabela.numero_parcela']}"> 
            <h:outputText value="#{formaPagamento.parcelas.indexOf(parcela)+1}"/> 
           </p:column> 
           <p:column headerText="#{vendaMsg['popup.forma_pagamento.tabela.vencimento_parcela']}"> 
            <hrgi:editableDate value="#{parcela.dataVencimento}" editable="true"/> 
           </p:column> 
           <p:column headerText="#{vendaMsg['popup.forma_pagamento.tabela.valor_parcela']}"> 
            <hrgi:spinner id="valor" 
              dinheiro="true" fator="0.01" local="pt-BR" 
              value="#{parcela.valor}"> 
             <f:ajax event="change" execute="@form" 
               render=":#{cabecalhoValores.clientId}"/> 
             <f:convertNumber currencySymbol="R$" maxFractionDigits="2" 
                 minFractionDigits="2" type="currency" currencyCode="BRL" 
                 for="input"/> 
            </hrgi:spinner> 
           </p:column> 
          </p:dataTable> 
         </h:panelGroup> 
        </h:panelGroup> 
       </hrgi:accordion> 
      </ui:repeat> 
     </h:panelGroup> 
     <p:commandLink immediate="true" action="#{controladorPopupFormaPagamento.adicionarForma}" 
         update="painelFormasDePagamento" global="false"> 
      <h:graphicImage library="img" name="adicionar_48.png"/> 
     </p:commandLink> 
    </h:panelGroup> 
</ui:define> 
</ui:composition> 

在這張照片你可以看到發生了什麼,組件的id內primefaces數據表中不與UI附加:重複索引:

html inspector

如何我可以解決這個問題嗎?

回答

7

這是一個鑽嘴魚科的錯誤,當你窩在UIRepeat內的UIData組件,它體現。我曾經把它報告爲issue 1830。到目前爲止還沒有修復,並且在MyFaces中按預期工作。在Mojarra,UIRepeat在許多方面都被打破,但在MyFaces中完美運行。

如果你想/需要堅持鑽嘴魚科,因此無法通過MyFaces的替換它,可以考慮由fullworthy UIData基於組件更換UIRepeatTomahawk's<t:dataList>例如不產生任何額外的標記,是一個很好<ui:repeat>更換。或者你可以使用PrimeFaces' <p:dataList>和隱藏列表槍彈一些CSS list-style-type: none

更新:報告的問題時固定在鑽嘴魚科2.1.12和2.2.0-M06。所以如果可以的話,只需升級到至少該版本。

+0

我已經更換到MyFaces的。希望它沒有奇怪的錯誤... – brevleq 2012-04-04 13:25:56

+0

沒有什麼是完美的,但MyFaces開發團隊在處理錯誤報告方面做得很好。 SO的MyFaces領導開發人員也很活躍。 – BalusC 2012-04-04 13:29:50