2016-01-18 49 views
0

我正在使用PrimeFaces 5.2。場景:關閉p:對話框後,不會調用event =「dialogReturn」

  1. 打開一個對話框,在列表中看到
  2. 在對話框中,在最後
  3. 顯示操作欄,關閉對話框
  4. 重定向到選定的操作頁面在列。

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

可以直接返回URL像 回報「?myDetails面重定向=真」; – vinod

+0

我可以,但是在關閉對話框時不會執行該方法。如果我在selectedFileIdForDetails中寫入重定向代碼,其中對話框正在關閉,那麼重定向頁面會在對話框中打開 – vicky

+0

您是否在'dialogReturn'函數打印了任何日誌? – YouYou

回答

0

更改爲Java方法無 '()'

<p:ajax event="dialogReturn" update="@form" listener="#{userDashboardBacking.dialogReturn}" /> 

,並在您dialogReturn()方法中添加SelectEvent作爲輸入參數,以你的方法

public void dialogReturn(SelectEvent event){ 
    Long selectedId = (Long) event.getObject(); 
} 
+0

添加SelectEvent沒有區別。 PF6中的DF支持兩者。 – tak3shi

相關問題