掲示板

redirection to another portlet

thumbnail
10年前 に ALex joubert によって更新されました。

redirection to another portlet

Junior Member 投稿: 27 参加年月日: 10/03/19 最新の投稿
Hello,

I want to make a link in my XHTML that makes the redirection to another portlet.

Thanks
thumbnail
10年前 に Kyle Joseph Stiemann によって更新されました。

RE: redirection to another portlet

Liferay Master 投稿: 760 参加年月日: 13/01/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:
<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