primefaces - p:单击时不显示对话框
问题描述
我正在使用 PrimeFaces 3,下面给出了我的 xhtml 页面。
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<h:outputScript name="jquery.js" library="css"></h:outputScript>
</h:head>
<h:body>
<p:panel id="allPaymentMethods" header="Payment Method"
style="font-weight: bold;font-size:14px"
rendered="#{userRegistrationVo.paymentmethod}">
<table width="100%">
<tr>
<td>You can pay<br></br> <p:graphicImage
value="/images/dd.jpg" height="80" width="120" /><br></br>
<p:commandButton id="showEbpDialog" type="button"
value="Via Bank" onclick="ebpDlg.show()" >
</p:commandButton>
</td>
</tr>
</table>
<!-- epayment dialog starts here -->
<br />
<br />
<br />
<!-- epayment dialog ends here -->
<p:dialog widgetVar="ebpDlg" modal="true" width="700" height="500">
<p:panel header="Generate EBP for Bank Payment">
<p:commandButton value="Print" type="button" icon="ui-icon-print">
<p:printer target="generateebp" />
</p:commandButton>
<p:panel id="generateebp">
<table width="100%">
<tr>
<td colspan="3">
<table width="100%">
<tr>
<td></td>
<td>
<!-- <h:commandButton update="generateebp"
action="#{controller.payViaBank}" type="button"
value="Generate EBP No." oncomplete="hideGenerateButton()"
rendered="#{userRegistrationVo.hideButton}" id="ebpButton">
<f:ajax render="generateebp" execute="@this">
</f:ajax>
</h:commandButton> -->
<p:commandButton
value="E-payment" action="#{controller.payViaBank}"
process="@this" update="generateebp">
</p:commandButton>
</td>
</tr>
<tr>
<td></td>
<td align="center" valign="top"><p:graphicImage
value="/images/nepal_logo.png" height="60" width="90" /> <br></br>
<br></br></td>
</tr>
<tr>
<td></td>
<td align="center" valign="top"><h:outputLabel
value="लोक सेवा आयोग" style="font-size:14px;" /></td>
</tr>
<tr>
<td></td>
<td align="center"><h:outputLabel
value="परिक्षा शुल्क तिर्न EBP नम्बर लिनुहोस् । "
style="font-size:14px;" /></td>
</tr>
</table>
</td>
</tr>
</table>
<!-- viewing table -->
<table style="text-align: center" class="ebpTable">
<tr>
<td><h:outputLabel value="Advertisement Code"
style="background-color:#EAF0F8"></h:outputLabel></td>
<td><h:outputLabel value="Total Amount Due"
style="background-color:#EAF0F8"></h:outputLabel></td>
<td><h:outputLabel value="EBP Code"
style="background-color:#EAF0F8"></h:outputLabel></td>
<td><h:outputLabel value="Last Submission Date"
style="background-color:#EAF0F8"></h:outputLabel></td>
</tr>
<tr>
<td><h:outputText value="#{epaymentVo.advertisementcode}" />
</td>
<td><h:outputText value="#{epaymentVo.total}" /></td>
<td><h:outputText value="#{userRegistrationVo.ebpNumber}" />
</td>
<td><h:outputText
value="#{userRegistrationVo.lastApplicationDateNp}" /></td>
</tr>
</table>
<br />
<br />
<p>
मिती
<h:outputLabel
value="#{userRegistrationVo.lastApplicationDateNp}"></h:outputLabel>
गते बैन्किङ समय भित्र भुक्तान गरी सक्नुपर्नेछ। अन्यथा स्वय
उम्मेद्वार जिम्मेवार हुनु पर्ने छ ।
</p>
</p:panel>
</p:panel>
</p:dialog>
<br />
<br />
<br />
<hr />
<p:commandButton process="@this" update="@form" id="returnToAdvtBtn"
value="Back To Advertisement" action="#{controller.returnToAdvt}">
</p:commandButton>
</p:panel>
</h:body>
</f:view>
我试图在单击按钮时打开简单的对话框。现在我正在使用 PrimeFacesp:commandButton
来实现它。当我单击“通过银行”按钮时,没有任何反应(没有打开对话框)。因此,当我转到浏览器的控制台时,我看到:
未捕获的 ReferenceError:未定义 ebpDlg
但我已经明确定义了ebpDlg
对话框。我究竟做错了什么?
解决方案
您需要为您的对话框添加 ID,与 widgetVar 相同。
<p:dialog id="ebpDlg" widgetVar="ebpDlg" modal="true" width="700" height="500">
如果使用 widgetVar 调用,则需要添加 PF 函数,例如 PF('ebpDlg').show()
但我认为这适用于 4.0 以上版本。所以请检查您的版本。
推荐阅读
- python - 根据另一个中的值自行创建列
- python - 如何在python中将图像从(n,m,4)重塑为(n,m,3)?
- reporting-services - 根据另一列值计算一列的总和(SSRS)
- c# - Unity 中针对特定项目的 C# 编码问题
- google-apps-script - 根据内容查询返回命名范围
- python - 基于熊猫数据框中的值的单元格颜色编码背景
- php - 无法在 PHP 中使用 Bexio API 创建文章
- c# - 有没有办法创建通用映射器来检索对象内的集合?
- angular - 调用方法时显示覆盖,然后在结束时隐藏它
- jquery - 我想在散景 python 中单击选择和取消选择曲线