2016-05-10 83 views
2

我有一個任務流,有兩個視圖這樣的形象:重定向到同一任務流另一種觀點認爲編程上ADF

enter image description here

我有一個按鈕去那裏,但我並不需要點擊按鈕。我需要通過調用動作以編程方式重定向到另一個視圖。如何調用它,因爲我使用jsff作爲頁面。如果我使用

這種方法:

 FacesContext fctx = FacesContext.getCurrentInstance(); 
    UIViewRoot root = fctx.getViewRoot(); 
    //client Id of button includes naming container like id of region. 
    RichCommandButton button = 
     (RichCommandButton) root.findComponent("cb1"); 
    ActionEvent actionEvent = new ActionEvent(button); 
    actionEvent.queue(); 
    } 

我得到一個錯誤,如找不到組件。如果我使用頁面模板ID,我也會得到一個像編譯器找不到該組件的錯誤。你有另一種方法來解決這個問題嗎?或者如果我找到錯誤的查找組件,你能否解決它?

回答

2

您有使用「網址瀏覽」並將其重定向到您的路徑:enter image description here

1

對於這樣的情況下,我使用以下代碼:

public static void navigateTo(String redirect) { 
    FacesContext facesContext = FacesContext.getCurrentInstance(); 
    NavigationHandler nh = facesContext.getApplication().getNavigationHandler(); 
    nh.handleNavigation(facesContext, null, redirect); 
} 

其中重定向參數是流動的情況下規則的名稱。