p:对话框内的commandButton不起作用

时间:2015-01-08 11:51:46

标签: jsf primefaces

我遇到了这个问题,我在这里搜索了Google上的一些页面,但没有一个答案适用于我。

我有以下对话框:

<!-- 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>

我的mbean有以下方法:

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

我已尝试删除mbean ActionEvent,但似乎没有任何效果。

2 个答案:

答案 0 :(得分:0)

为什么不简单地写

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

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

答案 1 :(得分:0)

问题是验证错误。由于某种原因,PF扩展的inputNumber不接受粘贴值或字段的其他形式的自动填充。

相关问题