我正在使用PrimeFaces 5.2。情形:
1,2,3正在发挥作用。
我尝试了很多东西,但在关闭它之后重定向却无法正常工作。我调用重定向代码时没有调用dialogReturn
方法。
我在MyFile.xhtml中成功加载了一个对话框。
<p:commandLink action="#{userDashboardBacking.showPriorityMyView()}"
class="myClass"
value="#{userDashboardBacking.priorityFilesLabel1} (#{userDashboardBacking.priorityFilesCount1})">
<p:ajax event="dialogReturn" update="@form" listener="#{userDashboardBacking.dialogReturn()}" />
</p:commandLink>
MyFileBacking.java
// this always get me to the required dialog/page
public void showPriorityMyView(){
Map<String, Object> options = new HashMap<String, Object>();
options.put("modal", true);
options.put("closable", true);
options.put("draggable", true);
options.put("resizable", true);
options.put("contentHeight", "500");
options.put("contentWidth", "1100");
RequestContext.getCurrentInstance().openDialog("priorityMyView", options, null);
}
// this method is never called.
public void dialogReturn(){
FacesContext facesContext = FacesContext.getCurrentInstance();
String outcome = "/myDetails.jsf?faces-redirect=true";
facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null,outcome );
}
MyDetailDlg.xhtml
<p:column width="10">
<h:commandLink update="@form" action="#{myViewDlgBacking.selectedFileIdForDetails(row.fileId)}" title="View Details" immediate="true"
styleClass="ui-icon ui-icon-search" />
</p:column>
MyViewDlgBacking.java
// successfully closes the dialogue.
public void selectedFileIdForDetails(Long itemId){
RequestContext.getCurrentInstance().closeDialog(0);
}
为什么dialogReturn
没有被调用,如何在关闭对话框后重定向到另一个页面?
答案 0 :(得分:0)
更改为没有&#39;()&#39;
的java方法<p:ajax event="dialogReturn" update="@form" listener="#{userDashboardBacking.dialogReturn}" />
并将SelectEvent作为输入参数添加到方法
public void dialogReturn(SelectEvent event){
Long selectedId = (Long) event.getObject();
}