Question

I want to show a dialog box on the click of a primefaces commandbutton. Before the dialog box , I need to check a condtional.

I am using Spring web-flow 2.3.0.

So I am doing it like this ,

And the Dialog Box is

I am not able to show this dialog box based on this condition.

Please help me ,any pointers?

SWF 2.3.0 Primefaces 2.2.1 JSF 2 Spring Security 3 Spring 3.1.0M1I EhCache Apache Tomcat 6.0 STS 2.5.1

So I have changed my code as per below

                    <p:commandLink id="addRequest" immediate="true" value="addreq"
                    oncomplete="dlg3.show()" update="dialogPanel">
                    <f:setPropertyActionListener
                        value="#{searchHandler.selectedAccIns}"
                        target="#{reqSearchHandler.checkAccStatus}" />
                </p:commandLink>

And the dialog box is

                <p:outputPanel id="dialogPanel"
                rendered="#{not reqSearchHandler.accStatusFlag}">
                <p:dialog header="Effect Dialog" widgetVar="dlg3"
                    showEffect="bounce" hideEffect="explode" height="200">
                    <h:outputText
                        value="Account is #{searchHandler.selectedAccIns.accStatusDesc}" />
                    <h:outputText value="Do you want to continue?" />
                    <div align="left">
                        <p:commandButton value="Yes" action="accept" />
                        <p:spacer width="960" height="5" />
                        <p:commandButton value="No" action="cancel" />
                    </div>
                </p:dialog>
            </p:outputPanel>

But when I am clicking on the command link , I am getting 3 dialog boxes. Can you please tell me why it is so?

Was it helpful?

Solution

Somebody else just posted the same problem! :)

You should use the oncomplete attribute instead of onclick of the commandButton. The click javascript event occurs before the page posts back, likely causing your dialog not to appear because of the page reloading.

oncomplete="dlg3.show()" will display the dialog AFTER the postback.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top