2

我正在尝试复制 Primefaces ajax 对话框形式,如 Primefaces 展示

我的 JSF 代码片段如下

<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>  

我的托管 bean

@ManagedBean  
@ViewScoped  

public class BackingBean implements Serializable{  


    private String firstName;  

    public String getFirstName() {  
        return firstName;  
    }  

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


}  

单击提交按钮时没有显示对话框:(。我还包括了 appendToBody="true" 但没有结果。即我得到 javascript 错误为“预期对象”。请帮我解决这个问题。

4

2 回答 2

5

您使用哪个版本的 primefaces ?

如果您使用 Primefaces 3.5 或更早版本:

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

对于 Primefaces 4.0:

<p:commandButton id="showDialogButton" type="button" value="Show"  
    onclick="PF('dlg').show()" />
于 2013-09-06T09:04:06.293 回答
2

就我而言,我在标题中有一个指向 jquery 的脚本链接。我放弃了它,primefaces 开始正常工作

于 2015-04-05T21:10:06.883 回答