2012-12-28 44 views
0

我正在創建一個primfaces portlet。從我的view.xhtml中調用我的bean類中的Submit方法。我想在輸入上重定向視圖庫。Liferay Primefaces Portlet重定向問題

下面是提交方法,我的代碼片段:

Submit(){ 
try { 
FacesContext.getCurrentInstance().getExternalContext().redirect("/views/Success.xhtml"); 
} catch (IOException e) 
{ 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
} 

它簡單地添加到本地主機URL爲http://localhost:8081/views/Success.xhtml。我想我可能錯過了一些重要的事情。如果是的話,應該實現一些渲染階段的方法,我怎麼去做,以便它爲該頁面創建渲染網址。

回答

0

你可以使用你爲什麼不使用普通的JSF導航此下面的代碼

FacesContext facesContext = FacesContext.getCurrentInstance(); 
    ExternalContext externalContext = facesContext.getExternalContext(); 
    PortletRequest portletRequest = (PortletRequest) externalContext 
      .getRequest(); 

    ThemeDisplay themeDisplay = (ThemeDisplay) req.getAttribute(WebKeys.THEME_DISPLAY); 
    PortletURL url = PortletURLFactoryUtil.create(req, 
      PortalUtil.getPortletId(req), 
      themeDisplay.getLayout().getPlid(), 
      PortletRequest.ACTION_PHASE); 
    url.setParameter("_facesViewIdRender", "/views/Success.xhtml"); 
    url.setWindowState(WindowState.NORMAL); 
    url.setPortletMode(PortletMode.VIEW); 
     FacesContext.getCurrentInstance().getExternalContext().redirect(url.toString()); 
1

創建的網址是什麼?在這種情況下,不需要打擾Portlet URL,因爲它將由JSF橋樑爲您處理。

public String submit() { 
    // do stuff; 
    return "/views/Success"; 
} 

可以省略.xhtml擴展。