gpt4 book ai didi

javascript - 显示

from javascript

转载 作者:行者123 更新时间:2023-12-02 17:54:31 27 4
gpt4 key购买 nike

我需要从 JavaScript 显示一个 p:confirmDialog

我已经尝试过:

<p:confirmDialog id="users"  widgetVar="UsersWidget" severity="alert" closable="false">

<h:outputText value="Please specify the UserID of the contractor to whom a mail need to be sent"></h:outputText>
<h:inputText></h:inputText>
<p:commandButton id="OK" value="add"></p:commandButton>
<p:commandButton style="font-size:1.1em;" id="Cancel"
value="cancel" action="#{Bean.Report}" >
</p:commandButton>

</p:confirmDialog>

<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{Bean.usersList}"/>
<f:selectItem itemLabel="Other" itemValue="Other" />
<p:ajax listener="check()" />

我的 JavaScript

<h:head>
<script language="javascript">
function check() {
alert("Entered");
RequestContext.getCurrentInstance().execute("UsersWidget.show()");
alert("Working!!");
}
</script>
</h:head>

我可以看到输入的警报,但我看不到符合对话框和工作警报

最佳答案

您正在混合 Java 和 JavaScript。

在 JavaScript 中,您只需执行以下操作:

<script language="javascript">
function check() {
alert("Entered");
UsersWidget.show();
alert("Working!!");
}
</script>

UsersWidget 对应于您在 p:confirmDialog 的属性 widgetVar 中设置的名称。

如果您想在调用后备 bean 后显示对话框,您可以在 Java 代码(后备 bean)中调用它:

public void myJavaMethod() {
RequestContext.getCurrentInstance().execute("UsersWidget.show()");
}

请求返回后,将立即显示该对话框。

关于javascript - 显示 <p :confirmDialog> from javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21089073/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com