不调用Primefaces命令按钮事件

时间:2015-04-08 23:56:57

标签: jsf primefaces

在Primefaces中,按钮将调用prepareCreate方法,然后打开表单对话框。问题是,此方法永远不会被调用,因此不会显示对话框中的表单。

命令按钮

<p:commandButton id="createButton1" value="#{bundle.Create}" actionListener="#{purchaseOrderController.prepareCreate}" 
     update=":PurchaseOrderCreateForm11" oncomplete="PF('PurchaseOrderCreateDialog11').show()"/>

对话框

<p:dialog id="PurchaseOrderCreateDlg11" widgetVar="PurchaseOrderCreateDialog11" modal="true" resizable="false" appendTo="@(body)" header="#{bundle.CreatePurchaseOrderTitle}">
    <h:form id="PurchaseOrderCreateForm11">
        <h:panelGroup id="display">
            <p:panelGrid columns="2" rendered="#{purchaseOrderController.selected != null}">
                <p:outputLabel value="#{bundle.CreatePurchaseOrderLabel_orderNum}" for="orderNum" />
                <p:inputText id="orderNum" value="#{purchaseOrderController.selected.orderNum}" title="#{bundle.CreatePurchaseOrderTitle_orderNum}" required="true" requiredMessage="#{bundle.CreatePurchaseOrderRequiredMessage_orderNum}"/>
                <p:outputLabel value="#{bundle.CreatePurchaseOrderLabel_quantity}" for="quantity" />
                <p:inputText id="quantity" value="#{purchaseOrderController.selected.quantity}" title="#{bundle.CreatePurchaseOrderTitle_quantity}" />
                <p:outputLabel value="#{bundle.CreatePurchaseOrderLabel_shippingCost}" for="shippingCost" />
                <p:inputText id="shippingCost" value="#{purchaseOrderController.selected.shippingCost}" title="#{bundle.CreatePurchaseOrderTitle_shippingCost}" />
            </p:panelGrid>
            <p:commandButton actionListener="#{purchaseOrderController.create}" value="#{bundle.Save}"  oncomplete="handleSubmit(args,'PurchaseOrderCreateDialog11');"/>
            <p:commandButton value="#{bundle.Cancel}" onclick="PurchaseOrderCreateDialog11.hide()"/>
        </h:panelGroup>
    </h:form>
</p:dialog>

JSF托管bean

@Named("purchaseOrderController")
@SessionScoped
public class PurchaseOrderController implements Serializable {

    public PurchaseOrder prepareCreate() {
        System.out.println("Purchase order prepare create");
        selected = new PurchaseOrder();
        initializeEmbeddableKey();
        return selected;
    }

}

0 个答案:

没有答案