0

I have this problem and I search here and some pages on Google and none of the answers worked for me.

I have the following dialog:

<!-- Dialog Fechar Pedido -->
<p:dialog header="Fechar Pedido" widgetVar="clsPedido" id="clsPedido" minWidth="550">
    <h:form prependId="true" id="frmClsPedido">
        <p:panel id="pnlDialogClsPedido" header="Informe a forma de pagamento">
        <h:panelGrid id="grdClsPedido" columns="2" cellpadding="5">
            <p:outputLabel value="Valor Total:." />
            <p:outputLabel value="R$ #{pedidoMB.totalPedido}"  size="5" style="color: red;">
                <f:convertNumber currencySymbol="R$" integerOnly="true" pattern="#0.00" locale="pt_BR" minFractionDigits="1" minIntegerDigits="1" />
            </p:outputLabel>

            <p:outputLabel value="Valor Recebido:." />
            <pe:inputNumber id="vlrRecebido" value="#{pedidoMB.vlrRecebido}" minValue="0" required="true" onblur="returnValue(this.value)" requiredMessage="Informe o valor recebido!" decimalPlaces="2" decimalSeparator="," thousandSeparator="." />

            <p:outputLabel value="Pagamento em:." />
            <p:selectOneRadio id="frmPagamento" value="#{pedidoMB.frmPagamento}" onchange="daTroco(this.value);" required="true" requiredMessage="Informe a forma de pagamento!">
                <f:selectItem itemLabel="Dinheiro" itemValue="DIN" />
                <f:selectItem itemLabel="Débito" itemValue="DEB" />
                <f:selectItem itemLabel="Crédito" itemValue="CRED" />
                <f:selectItem itemLabel="Vale Refeição" itemValue="REF" />
            </p:selectOneRadio>

            <p:outputLabel value="Valor Troco:." />
            <p:inputText value="#{pedidoMB.vlrTroco}" size="5" style="color: blue;" id="vlrTroco" widgetVar="vlrTroco" readonly="true">
                <f:convertNumber currencySymbol="R$" integerOnly="true" pattern="#0.00" locale="pt_BR" minFractionDigits="1" minIntegerDigits="1" />
            </p:inputText>
        </h:panelGrid>

        <h:messages></h:messages>
        <div align="right">
            <p:commandButton icon="ui-icon-disk" actionListener="#{pedidoMB.doFecharPedido}" />
        </div>
        </p:panel>
    </h:form>
</p:dialog>

And I have the following method at my mbean:

public void doFecharPedido(ActionEvent event) {
    if (getId() != null) {
        Pedido p = getService().findById(getId());
        getService().fecharPedido(getVlrRecebido(), getVlrTroco(), p);
    }
}

I already tried removing the mbean ActionEvent but nothing seems to work.

Tiny
  • 27,221
  • 105
  • 339
  • 599
  • 1
    Have you excluded all of http://stackoverflow.com/questions/2118656/commandlink-commandbutton-ajax-backing-bean-action-listener-method-not-invoked/2120183? – BalusC Jan 08 '15 at 12:08
  • The problem was a validation error. For some reason the inputNumber from PF extension does not accept a paste value or some other form of automatic fill of the field. – Eduardo Santos Jan 10 '15 at 11:41

2 Answers2

0

Why not simply write

<p:commandButton icon="ui-icon-disk" action="#{pedidoMB.doFecharPedido}" />

and

public void doFecharPedido() {
    if(getId() != null) {
        Pedido p = getService().findById(getId());
        getService().fecharPedido(getVlrRecebido(), getVlrTroco(), p);
    }
}

?

Smutje
  • 17,733
  • 4
  • 24
  • 41
  • Merely changing `actionListener` to `action` basically will not help, if the said `actionListener` itself already fails. Furthermore, based on the scenario depicted, `actionListener` is basically more suitable, since the method is meant to return nothing (`void`) - it just does a post back. – Tiny Jan 08 '15 at 12:31
0

The problem was a validation error. For some reason the inputNumber from PF extension does not accept a paste value or some other form of automatic fill of the field.