Assigning unique name to portlet and page


When we use IBM's advanced generation url helper classes to hit target portlet on targeted page, this requires to create a target url.
Creating a target url requires Portlet's unique name and page unique name.
Here is code snippet to create targetURL to portlet on a page.

String targetURLStr = PortletURLHelper.generateUrl(pageName, portletName, params, request, response);

this will generate a url to the specified pageName and portletName in the parameter list.

Params are the parameters that you want to pass to the target portlet and these are array of strings stored in HashMap.

Example:-
HashMap map = new HashMap();
String[] paramValue = {"param value"};
map.put("paramKey", paramValue);

Now, the portlet namae and page name we specify in parameter list, must be unique name.Portlet UniqueName should only be assigned using XML Access and page name can be assigned from portal admin UI.
Here i am assuming, our Source portlet is Portlet A on page A, and target portlet is Portlet B on page B.From Portlet A, we generate a url to Portlet B and make a call to
response.sendRedirect(targetURLStr) from Portlet A.

Here are the steps on how to assign portlet unique name via xml access

1) add Portlet B on page B

2) click on expot icon
3) save file as pageExport.xml

4) open pageExport.xml in editor and find the last portletinstance tag surrounded with component tag.

<component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_CGAH47L00OGOE0I83J5BNK0081" ordinal="100" type="control" width="undefined">
<portletinstance action="update" domain="rel" objectid="5_CGAH47L00OGOE0I83J5BNK0086" portletref="3_CGAH47L00OGOE0I83J5BNK00G2"/>
</component>
5) add uniquename attribute to the component tag.

uniquename="PortletBUniqueName"
now it should look like as below

<component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_CGAH47L00OGOE0I83J5BNK0081" ordinal="100" type="control" uniquename="PortletBUniqueName" width="undefined">
<portletinstance action="update" domain="rel" objectid="5_CGAH47L00OGOE0I83J5BNK0086" portletref="3_CGAH47L00OGOE0I83J5BNK00G2"/>
</component>

6) save the file.

7) Go to portal admin and click on import xml.

8) browse the path of saved pageExport.xml and click on import.

you should see message as
EJPAG1008I: The XMLAccess ran successfully please click the View Details link to view the output. View Details

Assigning unique name to Page B requires only to click on edit page properties of Page B and provide unique name value in the text box and click ok.

2 comments:

Anonymous said...

And what about I want to pass params to few portlets on page b?

Neeraj Sidhaye said...

do you mean, one source and miltiple portlets as target on the target page?