我正在使用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>
单击按钮时,我试图打开简单对话框。现在,我正在使用PrimeFaces p:commandButton
来实现它。当我单击“通过银行”按钮时,没有任何反应(没有对话框打开)。因此,当我进入浏览器的控制台时,会看到:
未捕获的ReferenceError:ebpDlg未定义
但是我已经明确定义了ebpDlg
对话框。我究竟做错了什么?
答案 0 :(得分:0)
您需要为对话框添加与widgetVar相同的ID。
<p:dialog id="ebpDlg" widgetVar="ebpDlg" modal="true" width="700" height="500">
如果使用widgetVar调用,则需要添加PF函数,例如PF('ebpDlg').show()
但是我认为这适用于4.0版以上。因此,请检查您的版本。