primefaces dialog not working

久未见 提交于 2019-12-23 23:00:08

问题


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.


回答1:


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()" />



回答2:


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



来源:https://stackoverflow.com/questions/18653803/primefaces-dialog-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!