0

In Primefaces, a button will call a prepareCreate method and then open the form dialog. The issue is, this method never get called so that the form in the dialog is not shown.

Command button

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

Dialog

<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 managed 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;
    }

}
Bruno Ribeiro
  • 5,956
  • 5
  • 39
  • 48
user595234
  • 6,007
  • 25
  • 77
  • 101
  • 1
    What version of primefaces? – Jorge Campos Apr 09 '15 at 00:59
  • Another thing, your code does not appear to be wrong, I have the same sort of code style on my end and it work. So, maybe there is some invalid component on your tree when you click on that button therefore your action does not get called. See the logs. Is this a valid object for the EL to process `#{bundle.Create}` ? – Jorge Campos Apr 09 '15 at 01:07
  • Does your commandButton is inside a form? – Jorge Campos Apr 09 '15 at 01:13
  • What purpose are oncomplete="handleSubmit(args,'PurchaseOrderCreateDialog11');" ? – 0x5a4d Apr 09 '15 at 01:36
  • Its a netbeans generated snippet that will hide the dialog only if there were no validation errors. @user595234 could you show some more of the calling page? Also what server, and is everything else working? – Jaqen H'ghar Apr 09 '15 at 05:57
  • Check here: http://stackoverflow.com/questions/2118656/commandlink-commandbutton-ajax-backing-bean-action-listener-method-not-invoked – Kukeltje Apr 09 '15 at 06:45

0 Answers0