2

I am trying to replicate primefaces ajax dialog form as in Primefaces showcase

My JSF code snippet is as below

<h:body>  

<p:commandButton id="showDialogButton" type="button" value="Show"  
    onclick="PF('dlg').show()" />  

<p:dialog header="Enter FirstName" widgetVar="dlg" appendToBody="true"  
    resizable="false">  
    <h:form id="form">  

        <h:panelGrid columns="2" style="margin-bottom:10px">  
            <h:outputLabel for="firstName" value="firstName:" />  
            <p:inputText id="firstName" value="#{backingBean.firstName}" />  
        </h:panelGrid>  

        <p:commandButton id="submitButton" value="Submit" update=":display"  
            oncomplete="PF('dlg').hide();" />  

    </h:form>  
</p:dialog>  

<p:outputPanel id="display" style="display:block;margin-top:10px;">  
    <h:outputText id="name" value="Hello #{backingBean.firstName}"  
        rendered="#{not empty backingBean.firstName}" />  
</p:outputPanel>  

My managed bean

@ManagedBean  
@ViewScoped  

public class BackingBean implements Serializable{  


    private String firstName;  

    public String getFirstName() {  
        return firstName;  
    }  

    public void setFirstName(String firstName) {  
        this.firstName = firstName;  
    }  


}  

No dialog is getting displayed on clicking submit button :(. I have also included appendToBody="true" but no result.In ie i get javascript error as "Object Expected". Please help me out to solve this issue.

xdev
  • 641
  • 6
  • 18
  • 38

2 Answers2

5

which version of primefaces you use ?

If you use Primefaces 3.5 or older:

<p:commandButton id="showDialogButton" type="button" value="Show"  
    onclick="dlg.show()" />  

For Primefaces 4.0 :

<p:commandButton id="showDialogButton" type="button" value="Show"  
    onclick="PF('dlg').show()" />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Joffrey Hernandez
  • 1,809
  • 3
  • 21
  • 39
  • Is the second one a javascript call? I just want to know the difference between those two calls. – Prasad Kharkar Sep 06 '13 at 09:07
  • Thanks a ton Lamq.I am using PF 3.5,as u mentioned ,this can only work with onclick="dlg.show() – xdev Sep 06 '13 at 09:18
  • what is the name for the `JavaScript` derivative dialect that assigned here as a value to the `onclick` attribute? I am just looking for the name of the dialect or expression language within `PrimeFaces` – amphibient Dec 02 '14 at 17:06
  • I use Primefaces 3.5 , but onclick="dlg.show()" doesnt works in IE10-11. So what can I do? – MeetJoeBlack Nov 26 '15 at 07:35
2

In my case I had a script link to jquery in header. I droped it and primefaces started to work correctly

spok
  • 91
  • 1
  • 2