Showing posts with label url. Show all posts
Showing posts with label url. Show all posts

Wednesday, September 16, 2009

Nested URL opens in new browser window instead of current window

How do i do :
In IBM WebSphere Portal, when creating a new external URL using the Manage Pages administration portlet, it behaves differently depending on which the level used.

* Example 1: If you go to Content Root --> Home --> Level 2 URL (mapped to www.ibm.com) and leave Portal administration, when you click the new URL, it opens www.ibm.com in the same window.

* Example 2: If you go to Content Root --> Home --> Welcome --> Level 3 URL (mapped to www.ibm.com) and leave Portal administration, when you click the new URL, it opens a new browser window for www.ibm.com.

Cause
The behavior is working as designed.


Resolution
In Example #2, the navigation exists on the left side of the page as opposed to across the top of the page as in Example #1.
To allow the links on the left navigation to open in the same window, remove any references in the page's theme to "target+"_blank"". This reference causes the link to open in a new window.

If using the default IBM theme, do the following:

-- Stop WebSphere Portal.
-- Remove the reference in the following files: Default.jsp and sideNav.jspf
-- Remove the temporary files for the IBM theme in/temp/cellname/WebSphere_Portal/themes.
-- Start WebSphere Portal.
-- Click the link again. It should open in the same window.

Tuesday, March 24, 2009

Use Portal 6.0 Advanced URL Generation Helper Class ServletURLGenerator to Generate URL of portlet

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:



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);
%>



Link

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