3

スピナーを実装する複合コンポーネントを作成しました。うまく動作しますが、primefaces 2.2.1 から primefaces 3.3.1 に変更すると、f:ajax の代わりに p:ajax を使用しようとすると、コンポーネントがすべてのページでクラッシュします。

コンポーネントは次のとおりです。

<c:interface>
    <c:attribute name="value" required="true"/>
    <c:attribute name="fator" required="false" default="1"/>
    <c:attribute name="required" required="false" default="false"/>
    <c:attribute name="requiredMessage" required="false" default=""/>
    <c:attribute name="validatorMessage" required="false" default="Não é um número válido!"/>
    <c:attribute name="disabled" required="false" default="false"/>
    <c:attribute name="title" required="false" default=""/>
    <c:attribute name="width" required="false" default="100"/>
    <c:attribute name="dinheiro" required="false" default="false"/>
    <c:attribute name="local" required="false" default="pt-BR"/>
    <c:attribute name="imediato" required="false" default="false"/>
    <c:attribute name="onchange" required="false" default=""/>
    <c:attribute name="onkeyup" required="false" default=""/>
    <c:attribute name="max" required="false" default="-1"/>
    <c:attribute name="min" required="false" default="0"/>
    <c:attribute name="parametro" required="false" default=""/>
    <c:attribute name="casasDecimais" required="false" default="2"/>
    <c:attribute name="valueChangeListener" method-signature="void method(javax.faces.event.ValueChangeEvent)"
                 targets="spinner"/>
    <c:attribute name="rendered" required="false" default="true"/>
    <c:editableValueHolder name="#{cc.id}" targets="spinner"/>
    <c:clientBehavior name="blur" default="true" event="blur"
                      targets="spinner"/>
    <c:clientBehavior name="change" default="true" event="change"
                      targets="spinner"/>
</c:interface>

<c:implementation>
    <h:outputStylesheet library="css" name="hrgiSpinner.css" target="head"/>
    <h:outputScript library="js" name="jquery.formatCurrency-1.4.0.min.js" target="head"/>
    <h:outputScript library="js" name="jquery.formatCurrency.pt-BR.js" target="head"/>
    <h:outputScript library="js" name="hrgiSpinner.js" target="head"/>
    <h:panelGroup layout="block" styleClass="hrgi-spinner" rendered="#{cc.attrs.rendered}">
        <p:inputText id="spinner" value="#{cc.attrs.value}"
                     styleClass="hrgi-spinner-input editableField" disabled="#{cc.attrs.disabled}"
                     onchange="formatar(this,'#{cc.attrs.fator}','#{cc.attrs.local}','#{cc.attrs.dinheiro}','#{cc.attrs.max}','#{cc.attrs.min}','#{cc.attrs.casasDecimais}'); #{cc.attrs.onchange}"
                     required="#{cc.attrs.required}" requiredMessage="#{cc.attrs.requiredMessage}"
                     validatorMessage="#{cc.attrs.validatorMessage}" onkeyup="#{cc.attrs.onkeyup}"
                     title="#{cc.attrs.title}" immediate="#{cc.attrs.imediato}" style="width: #{cc.attrs.width}px;"
                     converterMessage="O valor informado não é um número.">
            <f:attribute name="objeto" value="#{cc.attrs.parametro}"/>
        </p:inputText>
        <h:panelGroup layout="block" styleClass="hrgi-spinner-painel-botoes"
                      rendered="#{not cc.attrs.disabled}">
            <div onmousedown="incrementar('#{cc.clientId}'+':spinner','#{cc.attrs.fator}','#{cc.attrs.local}','#{cc.attrs.dinheiro}','#{cc.attrs.max}','#{cc.attrs.min}','#{cc.attrs.casasDecimais}');"
                 class="hrgi-spinner-botao hrgi-spinner-botao-alto clearfix"/>
            <div onmousedown="decrementar('#{cc.clientId}'+':spinner','#{cc.attrs.fator}','#{cc.attrs.local}','#{cc.attrs.dinheiro}','#{cc.attrs.max}','#{cc.attrs.min}','#{cc.attrs.casasDecimais}');"
                 class="hrgi-spinner-botao hrgi-spinner-botao-baixo clearfix"/>
        </h:panelGroup>
        <h:panelGroup layout="block"
                      styleClass="hrgi-spinner-painel-botoes hrgi-spinner-painel-botoes-desabilitados"
                      rendered="#{cc.attrs.disabled}">
            <div class="hrgi-spinner-botao hrgi-spinner-botao-alto clearfix"/>
            <div class="hrgi-spinner-botao hrgi-spinner-botao-baixo clearfix"/>
        </h:panelGroup>
    </h:panelGroup>
</c:implementation>

f:ajax を使用する場合:

 <hrgi:spinner id="aliquotaIpiItem" rendered="#{itemEmbrulhado.carregado}"
     disabled="#{not modeloPopupLancamentoNF.lancamentoDanfe}"
     value="#{controladorTabelaDinamicaItemNF.recuperarIPI(itemEmbrulhado).aliquota}"
     dinheiro="false" fator="0.01" local="pt-BR" min="0.00" width="70"
     parametro="#{itemEmbrulhado}">
     <f:ajax render=":lancamentoNF:abasNF:painelItensNF :alerta" execute="@form"
         event="blur" listener="#{controladorPopupLancamentoNF.validarAliquotasItemEAdicionar}"
         onevent="definirFoco"/>
     <f:convertNumber maxFractionDigits="2" minFractionDigits="2" locale="#{cc.attrs.local}"
         for="aliquotaIpiItem"/>
 </hrgi:spinner>

普通

p:ajax を使用する場合:

<hrgi:spinner id="aliquotaIpiItem" rendered="#{itemEmbrulhado.carregado}"
    disabled="#{not modeloPopupLancamentoNF.lancamentoDanfe}"
    value="#{controladorTabelaDinamicaItemNF.recuperarIPI(itemEmbrulhado).aliquota}"
    dinheiro="false" fator="0.01" local="pt-BR" min="0.00" width="70"
    parametro="#{itemEmbrulhado}">
    <p:ajax update=":lancamentoNF:abasNF:painelItensNF :alerta" process="@form"
        event="blur" listener="#{controladorPopupLancamentoNF.validarAliquotasItemEAdicionar(itemEmbrulhado)}"
        onsuccess="salvarFoco();" oncomplete="carregarFoco(); exibirPopupAlerta(xhr, status, args);"/>
    <f:convertNumber maxFractionDigits="2" minFractionDigits="2" locale="#{cc.attrs.local}"
        for="aliquotaIpiItem"/>
</hrgi:spinner>

墜落した

誰かが私に何が起こっているのか説明できますか??

4

2 に答える 2

2

PrimeFaces ajax コンポーネントは、他の Primefaces コンポーネントとのみ使用する必要があります。このような複合コンポーネントの clientBehavior として挿入して、それが機能することを期待できるとは思いません。を使用する必要がありますf:ajax

余談ですが、PrimeFaces 3.0 からp:spinnerコンポーネントが導入されたため、複合コンポーネントは印象的な努力ではありますが、もはや必要ありません。:)

于 2012-08-23T12:35:06.073 に答える
1

As @maple_shaft said, I was unable to pass p:ajax to composite component. Primefaces has an spinner component, but unfortunately it still isn't good (doesn't support internationalization and show extra decimal numbers like 0.06666666669 instead of 0.07) and I don't have enough time to wait for the correction. Are rares the cases that I need use p:ajax with this component, generally just to get args like validationFailed. So, I've solved the problem using an ugly workaround:

<hrgi:spinner id="aliquotaIpiItem" rendered="#{itemEmbrulhado.carregado}"
     disabled="#{not modeloPopupLancamentoNF.lancamentoDanfe}"
     value="#{controladorTabelaDinamicaItemNF.recuperarIPI(itemEmbrulhado).aliquota}"
     dinheiro="false" fator="0.01" local="pt-BR" min="0.00" width="70"
     onblur="adicionarItemNF();">
     <f:convertNumber maxFractionDigits="2" minFractionDigits="2" locale="#{cc.attrs.local}"
         for="aliquotaIpiItem"/>
</hrgi:spinner>
<p:remoteCommand name="adicionarItemNF" update=":lancamentoNF:abasNF:painelItensNF :alerta" process="@form"
    action="#{controladorPopupLancamentoNF.validarAliquotasItemEAdicionar(itemEmbrulhado)}" global="false"
    onsuccess="salvarFoco();" oncomplete="carregarFoco(); exibirPopupAlerta(xhr, status, args);"/>
于 2012-08-23T18:18:47.913 に答える