如何使用JSF在Liferay Portal中重定向
使用jsf在liferay中重定向到portlet内的另一个页面的方法是什么?我一直在通过javascript尝试window.location.href,但它试图重定向页面,而不是门户。这取决于您要重定向到哪个页面如何使用JSF在Liferay Portal中重定向,jsf,jsf-2,liferay,liferay-6,Jsf,Jsf 2,Liferay,Liferay 6,使用jsf在liferay中重定向到portlet内的另一个页面的方法是什么?我一直在通过javascript尝试window.location.href,但它试图重定向页面,而不是门户。这取决于您要重定向到哪个页面 重定向到另一个portlet的第一页 假设您有portlet1,并且希望从portlet1重定向到portlet2。如果portlet2的URL是http:/yourDomain/web/portal/portlet2,那么下面的代码将从portlet1重定向到portlet2的
- 重定向到另一个portlet的第一页
假设您有portlet1,并且希望从portlet1重定向到portlet2。如果portlet2的URL是http:/yourDomain/web/portal/portlet2,那么下面的代码将从portlet1重定向到portlet2的第一页
FacesContext context=FacesContext.getCurrentInstance()代码>
javax.faces.context.ExternalContext=context.getExternalContext()代码>
externalContext.redirect(“/web/portal/portlet2”)代码>
phaselistener
或portlet.xml
中)显示您的第一页
- 从Portlet1重定向到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>
成功
/yourRequiredPage.jsf
这取决于要重定向到的页面
- 重定向到另一个portlet的第一页
假设您有portlet1,并且希望从portlet1重定向到portlet2。如果portlet2的URL是http:/yourDomain/web/portal/portlet2,那么下面的代码将从portlet1重定向到portlet2的第一页
FacesContext context=FacesContext.getCurrentInstance();
javax.faces.context.ExternalContext=context.getExternalContext();
externalContext.redirect(“/web/portal/portlet2”);
phaselistener
或portlet.xml
中)显示您的第一页
- 从Portlet1重定向到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>
成功
/yourRequiredPage.jsf