Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JSF在Liferay Portal中重定向_Jsf_Jsf 2_Liferay_Liferay 6 - Fatal编程技术网

如何使用JSF在Liferay Portal中重定向

如何使用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的

使用jsf在liferay中重定向到portlet内的另一个页面的方法是什么?我一直在通过javascript尝试window.location.href,但它试图重定向页面,而不是门户。

这取决于您要重定向到哪个页面

  • 重定向到另一个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”)

上述代码将命中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>

成功
/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”);

上述代码将命中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>

成功
/yourRequiredPage.jsf