primefaces - Can't redirect to other page when clicking a commandButton in dialog
问题描述
Hi guys I try to make a dialog, it's like when click submit the dialog will show up and if you click Ok it will redirect to other page but when I try click it its's doesnt work how to fixed it ??
this the code
<p:dialog modal="true" widgetVar="successDialog" header="Info"
closable="false" appendTo="@(body)">
<h:panelGrid columns="1" cellpadding="2">
<h:outputText value="Save data berhasil" />
<center>
<p:commandButton value="Ok"
action="/prpk_paperless/master_prpk.xhtml?faces-redirect=true"
onclick="PF('successDialog').hide()" immediate="true"/>
</center>
</h:panelGrid>
</p:dialog>
<p:dialog modal="false" widgetVar="failedDialog" header="Info"
closable="false">
<h:panelGrid columns="1" cellpadding="2">
<h:outputText value="Save data failed" />
<center>
<p:commandButton value="Ok" action="#"
onclick="PF('failedDialog').hide()" />
</center>
</h:panelGrid>
</p:dialog>
thank you..
解决方案
你可以试试:
实用程序.java:
public static void RedirectToURL( final String url ) {
FacesContext FC = FacesContext.getCurrentInstance();
try {
FC.getExternalContext().redirect( url );
} catch ( Exception e ) { /* do some useful */ }
FC.responseComplete();
}
bean.java
public void function buttonOk() {
RedirectToURL("/prpk_paperless/master_prpk.xhtml");
}
在 xhtml 中:
<p:commandButton value="Ok" actionListener="#{bean.buttonOk()}" onclick="PF('successDialog').hide()"/>
推荐阅读
- html - 边缘浏览器上的 Parse.cloud.run 功能故障(尝试重定向页面)
- java - 如何在 spotbug 报告中标记误报
- kotlin - Kotlin 类型擦除 - 为什么仅在泛型类型上不同的函数可编译,而仅在返回类型上不同的函数不是?
- wordpress - WordPress 列出 AZ 索引中的所有/选定页面
- sql - Red Gate Oracle Schema 比较 v3 和 v4 不解释 UserObjectPrivileges
- c# - 如何使用 Xero API 更新联系人的批量支付帐户名称和详细信息
- c - 如何将天转换为年月周然后天
- javascript - 问题
关于角材料设计 - python - Qt3D:根据实体和相机之间的距离缩放实体大小
- pytorch - 在 PyTorch 中用张量索引多维张量