2012-07-18 54 views
0

我有與對這個問題:菜單項 - 使用PF 3.3.1,3.3.3 PrettyFaces和JSF/Mojarra2.1。號碼:菜單項行動和行動處理重定向 - WINDOWID被釘在結束重定向URL

所以我有一組P的:需要通過從當前頁面的「ID」參數的菜單項。但是,我不希望構建以下形式的URL:/ page/targetPage?id = id & faces-redirect = true。我想要做的是,在頁面動作處理程序上,重定向到有問題的URL。但是,問題在於所產生的重定向會將windowId附加到最後,並且我無法訪問targetURL!

<p:menuitem action="#{myActions.performAction}" ajax="false" value="navigateToThisAction"/> 

在我的支持bean:

在我的facelet

public String performAction() { 
    return navigate("pretty:myAction"); 
} 

protected String navigate(String mappingId) { 
    HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); 
    PrettyContext context = PrettyContext.getCurrentInstance(request); 
    PrettyURLBuilder builder = new PrettyURLBuilder(); 

    UrlMapping mapping = context.getConfig().getMappingById(mappingId); 
    String targetURL = builder.build(mapping, true, getId()); 

    try { 
     FacesContext.getCurrentInstance().getExternalContext().redirect(targetURL); 
    } catch (IOException ioe) { 
     System.out.println("Error redirecting..." + ioe.getMessage()); 
    } 
    return null; 

} 
+0

PS - 結果在瀏覽器中是一樣的東西:HTTP://本地主機:年底(我覺得)我得到一個404 8080 /頁/ myAction/10651 = WINDOWID公元前因爲窗口的id沒有發現?錯誤.... – Nena 2012-07-18 00:08:54

+0

如果刪除這個'WINDOWID = '在瀏覽器中手動你仍然得到404錯誤? – 2012-07-18 00:14:08

+0

都能跟得上 - 它工作得很好...... – Nena 2012-07-18 00:17:05

回答

0

如果WINDOWID = xxxxx是由您的來電FacesContext.getCurrentInstance().getExternalContext().redirect(targetURL);添加,那麼你可能要檢查你的框架,看看有什麼補充。 PrettyFaces不會添加一個windowId參數,所以我猜測它是別的,你正在使用的一些其他庫,並且可能有辦法在給定頁面上手動禁用它。

0

我發現,問題是,我是缺少在網址前request.getContextPath()重定向之前 - 感謝所有的答覆!