如何使用jsf將liferay重定向到portlet中的另一個頁面?我一直在嘗試window.location.href通過javascript,但它試圖重定向頁面而不是門戶網站。如何在使用JSF的Liferay Portal中重定向
0
A
回答
2
這取決於您要重定向到哪個頁面。
重定向到另一個portlet的第一頁。
假設你有portlet1和portlet1要重定向到portlet2。如果portlet2的網址爲http:/ YOURDOMAIN/網站/門戶/ portlet2然後下面的代碼會重定向到portlet2的第一頁從portlet1
FacesContext context = FacesContext.getCurrentInstance();
javax.faces.context.ExternalContext externalContext = context.getExternalContext();
externalContext.redirect("/web/portal/portlet2");
上面的代碼將打portlet2並根據您的歡迎頁面配置(在phaselistener
或portlet.xml
您的第一頁將顯示。
- 重定向到來自Portlet1的Portlet2的其他頁面(而不是歡迎頁面)。
假設您想要從Portlet1重定向到Portlet2的第3頁。在這種情況下,使用上面的代碼可以擊中Portlet2。這將調用PhaseListenter
。在這裏你可以檢查你想要重定向到哪個頁面,並據此使用下面的代碼。
if(someConditionIsMet)
{
FacesContext context = FacesContext.getCurrentInstance();
UIViewRoot newPage = context.getApplication().getViewHandler().createView(context,"/your3rdPage.jsf");
context.setViewRoot(newPage);
context.renderResponse();
}
- 重定向到一些頁面在同一Portlet
我想你是不是這種情況尋找答案。儘管如此,我仍然認爲我不完全清楚你的問題。
比方說,你是通過h:commandLink
或h:commandButton
調用的鏈接。你正在調用一個方法(它返回String
)。然後可以使用下面的代碼。
public String someMethod()
{
//Do your checks here
return "success";
}
這在你的faces-config.xml
文件中進行配置。
<navigation-rule>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/yourRequiredPage.jsf</to-view-id>
</navigation-case>
</navigation-rule>
相關問題
- 1. Liferay:如何配置Liferay Portal
- 2. 使用response.sendRedirect在Liferay portlet中重定向
- 3. 在Liferay Portal
- 4. 如何在liferay portal嚮導中設置JDBC連接字符串?
- 5. 在Liferay Portal中自定義CreateAccountAction
- 6. Liferay:如何在Liferay中使用RequestDispatcher重定向到公共頁面
- 7. OpenSessionInViewFilter +在JSF中重定向
- 8. 如何在Backbase Portal 5.2.1.2中實現JSF?
- 9. Liferay Portal:與Websphere Portal有何不同
- 10. ajax call liferay portal
- 11. Liferay portal的通用gridview
- 12. Liferay Portlet和JSF:在渲染階段重定向
- 13. 重定向頁面使用JSF PhaseListener在
- 14. 如何在portal-ext.properties中停用liferay中的緩存
- 15. 在Liferay Portal上配置JAAS
- 16. Liferay portal-ext.properties在哪裏?
- 17. 如何使用PrimeFaces在JSF上重定向?
- 18. 如何在second.jsp上從first.jsp在LIFERAY中重定向?
- 19. 來自beanclass的liferay中的重定向
- 20. URL重定向JSF
- 21. 從jsf重定向?
- 22. 從Liferay Portal EE 6.1.20遷移到Liferay Portal CE 6.1.1
- 23. 如何在JSF中重定向到Ajax調用?
- 24. 如何使用JSF創建簡單的重定向?
- 25. 重定向到Liferay Portlet中的Java Servlet
- 26. Liferay頁面重定向
- 27. Liferay 6:portlet:renderURL不重定向
- 28. 在Liferay Portal中構建網站?
- 29. 如何在Liferay portal中實現友好的URL
- 30. 如何使用eclipse連接Liferay Portal和mysql數據庫?