Intention
In some cases, you might want to open a single portlet in a new window in solo state (which hides the portal theme elements, like a banner, page navigation, or tool bar), for example,
This main portlet contains one link, after click the link, the PopUpTest portlet which resides on the XuTest2 page will be displayed on a new window.
The XuTest2 page has more than one portlet:
therefore, the question comes: how to generate url of the target portlet. WebSphere Portal 6.0 provides some advanced URL generation helper classes to solve this problem. I am going to demonstrate the usage of ServeletURLGenerator.generateUrlForFlyout.
Investigating the generateUrlForFlyout function
public static EngineURL generateUrlForFlyout(
String pageName, String portletName,
HttpServletRequest request,
HttpServletResponse response)*
* This is the updated version of the one provide on Portal 6.0.x Advanced URL Generation Helper classes.
This function requires four parameters where
- pageName: the unique name of the target portlet page
- portletName: the unique name of target PortletWindow
To set the unique name of page, you can use either XMLAccess or through “Manage Custom Unique Names” portlet:
To set the unique name of PortletWindow, the only way is through XMLAccess to set the unique name of the component that holds the portlet instance on the page:
<component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_EKLFRHG008K3502T2LOQD130K2" ordinal="200" type="control" uniquename="xu.test.popuptest" width="undefined">
<portletinstance action="update" domain="rel" objectid="5_EKLFRHG008K3502T2LOQD130K4" portletref="3_EKLFRHG008K3502T2LOQD13040"/>
</component>
About how to do it, please refer to step1-4 of URLGeneration in WebSphere Portal v5.1.x - Linking to another portlet
Restrictions
As we see from the function above, to get it work, the target portlet must be assigned to a known page, which means, this API will not work if the portlet does not map to a page.
Code to generate URL
On the MainPortletView.jsp, we use the following code to generate URL of target portlet:
<%
try {
String pageName = "co.at.profile.XuTest2";
String portletName = "xu.test.popuptest";
EngineURL targetURLStr = ServletURLGenerator.generateUrlForFlyout(
pageName, portletName, request, response);
%>
<h:form id="form1" styleClass="form">
<br>
<a href='<%=targetURLStr %>'target="_new">Link</a>
</h:form>
Of course, to avoid the resolve exceptions, you need to include the necessary classes:
<%@page language="java" contentType="text/html"
pageEncoding="ISO-8859-1" session="false"
import="com.ibm.wps.l2.urlgeneration.helper.*,
com.ibm.portal.state.EngineURL"%>
Resources
Portal 6.0.x Advanced URL Generation Helper classes.
URLGeneration in WebSphere Portal v5.1.x - Linking to another portlet
BTW, many thanks to James Barnes.
本文介绍如何在 WebSphere Portal 6.0 中使用 ServeletURLGenerator 类的 generateUrlForFlyout 方法为特定的 Portlet 生成 URL,以便在新窗口中打开。此方法适用于希望在独立状态下显示 Portlet 的场景。

被折叠的 条评论
为什么被折叠?



