留言板
redirection to another portlet
Hello,
I want to make a link in my XHTML that makes the redirection to another portlet.
Thanks
I want to make a link in my XHTML that makes the redirection to another portlet.
Thanks
Kyle Joseph Stiemann,修改在10 年前。
RE: redirection to another portlet
Liferay Master 帖子: 760 加入日期: 13-1-14 最近的帖子
Hi Alex,
One way to do this is to use an actionListener on an h:commandLink. In your view.xhtml, the h:commandLink would look like this:
And in the java in YourBackingBean.java, the redirect() method would look like this:
If you want to short-circuit the JSF-lifecycle so that validation and all phases after it are skipped, you can add immediate="true" to the h:commandLink as well.
To use the LiferayFacesContext you will need the liferay-faces-portal jar, and to use the ThemeDisplay you will need portal-service.
Hope that helps,
- Kyle
One way to do this is to use an actionListener on an h:commandLink. In your view.xhtml, the h:commandLink would look like this:
<h:commandlink value="yourLinkText" actionListener="#{yourBackingBean.redirect}" />
And in the java in YourBackingBean.java, the redirect() method would look like this:
public void redirect() {
LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
ThemeDisplay themeDisplay = (ThemeDisplay) liferayFacesContext.getThemeDisplay();
String portalURL = themeDisplay.getPortalURL();
String redirect = portalURL + "/your/redirect/url";
try {
liferayFacesContext.getExternalContext().redirect(redirect);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
If you want to short-circuit the JSF-lifecycle so that validation and all phases after it are skipped, you can add immediate="true" to the h:commandLink as well.
To use the LiferayFacesContext you will need the liferay-faces-portal jar, and to use the ThemeDisplay you will need portal-service.
Hope that helps,
- Kyle