2014-02-19 105 views
0

一個簡單的問題,但不記得如何做到最好。我想要的是在代碼段運行後自動將用戶發送到另一頁"/lecturer/marking/marking-section-two"如何添加導航到支持bean

是否有一種方法可以在後臺bean中執行此操作,而不會影響之前顯示的ajax消息?

這是我運行

public void markSectionOne() { 
    //supposing the data in markSectionOne is filled... 
    this.markingFacade.create(markSectionOne); 
    this.setMessage("Mark Saved"); 
    //after saving... 
    markSectionOne = new Marking(); 
    // now navigating to the next page 
} 

的代碼,一旦它的運行我想自動定位到一個新的一頁。

謝謝你們

+2

將方法簽名更改爲'public String markSectionOne()'並返回重定向結果。結果可以註冊在** faces-config.xml中** <導航規則>' –

回答

2

你可以改變你的方法返回將被解讀爲下一個導航結果的字符串。

public String markSectionOne() { 
    // ... unrelevant code 
    return "/lecturer/marking/marking-section-two"; 
} 

如果該方法返回null,那麼JSF將保持在同一頁上。

+0

感謝:)我不知道如果改變方法返回一個字符串會影響它的功能,非常感謝:) – user2061913