Primefaces自动完成itemSelect事件未被触发

时间:2013-12-02 05:27:06

标签: jsf primefaces

在我的JSF应用程序中,不会触发Primefaces自动完成itemSelect事件。我仔细检查了它,它在一个表单元素中。我无法弄清楚为什么它不被解雇。

我在下面列出了代码。

                        <p:panelGrid columns="1" >
                            <p:outputLabel value="Medicine/Device" ></p:outputLabel>
                            <p:autoComplete   forceSelection="true"  id="acStock" value="#{pharmacySaleController.billItem.pharmaceuticalBillItem.stock}" converter="stockCon" completeMethod="#{pharmacySaleController.completeAvailableStocks}" var="i" itemLabel="#{i.itemBatch.item.name}" itemValue="#{i}" >
                                <p:column headerText="Item">
                                    <h:outputLabel value="#{i.itemBatch.item.name}" ></h:outputLabel>
                                </p:column>
                                <p:column headerText="Rate">
                                    <h:outputLabel value="#{i.itemBatch.retailsaleRate}" >
                                        <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                    </h:outputLabel>
                                </p:column>
                                <p:column headerText="Stocks">
                                    <h:outputLabel value="#{i.stock}" >
                                        <f:convertNumber pattern="#,###" ></f:convertNumber>
                                    </h:outputLabel>
                                </p:column>
                                <p:column headerText="Expiary">
                                    <h:outputLabel value="#{i.itemBatch.dateOfExpire}" >
                                        <f:convertDateTime pattern="MMM yyyy" ></f:convertDateTime>
                                    </h:outputLabel>
                                </p:column>
                                <p:ajax event="query" update="lstSelectItems" ></p:ajax>
                                <p:ajax event="itemSelect"  listener="#{pharmacySaleController.handleSelect}" update="txtRate txtQty txtVal" ></p:ajax>
                            </p:autoComplete>
                        </p:panelGrid>
                        <p:panelGrid columns="1" >
                            <p:outputLabel value="Quentity" ></p:outputLabel>
                            <p:inputText id="txtQty" value="#{pharmacySaleController.billItem.pharmaceuticalBillItem.qty}" >
                            </p:inputText>
                        </p:panelGrid>
                        <p:panelGrid columns="1" >
                            <p:outputLabel value="Rate" ></p:outputLabel>
                            <p:inputText id="txtRate" value="#{pharmacySaleController.billItem.rate}" >
                            </p:inputText>
                        </p:panelGrid>
                        <p:panelGrid columns="1" >
                            <p:outputLabel value="Value" ></p:outputLabel>
                            <p:inputText id="txtVal" value="#{pharmacySaleController.billItem.netValue}" >
                            </p:inputText>
                        </p:panelGrid>
                        <p:commandButton value="Add" action="#{pharmacySaleController.addBillItem()}" ></p:commandButton>


                    </p:panelGrid>

控制器

public void handleSelect(SelectEvent event){
    calculateRates();
}

public void calculateRates() {
    System.out.println("calculating rates");
    if (bill == null) {
        System.out.println("bill is null");
        return;
    }
    if (billItem == null) {
        System.out.println("billItem is null");
        return;
    }
    if (billItem.getPharmaceuticalBillItem() == null) {
        System.out.println("pharmaceutical bill item is null");
        return;
    }
    if (billItem.getPharmaceuticalBillItem().getStock() == null) {
        System.out.println("billItem.getPharmaceuticalBillItem().getStock() = " + billItem.getPharmaceuticalBillItem().getStock());
        return;
    }
    System.out.println("cal error check finished");
    //
    System.out.println("billItem.getPharmaceuticalBillItem().getStock().getItemBatch().getRetailsaleRate() = " + billItem.getPharmaceuticalBillItem().getStock().getItemBatch().getRetailsaleRate());
    billItem.setRate(billItem.getPharmaceuticalBillItem().getStock().getItemBatch().getRetailsaleRate());
    billItem.setDiscountRate(calculateBillItemDiscountRate(billItem));
    billItem.setNetRate(billItem.getRate() - billItem.getDiscountRate());

    billItem.setGrossValue(billItem.getRate() * billItem.getQty());
    billItem.setDiscount(billItem.getDiscountRate() * billItem.getQty());
    billItem.setNetValue(billItem.getNetRate() * billItem.getQty());

}

0 个答案:

没有答案