Topic
  • 1 reply
  • Latest Post - ‏2013-01-21T13:33:58Z by Gobozov_Georgy
Gobozov_Georgy
Gobozov_Georgy
51 Posts

Pinned topic Websphere portal 8 and url generation

‏2013-01-21T10:45:39Z |
Hello.
I am trying to generate render url from one portlet to another portlet on another page.
Everything looks fine, but render parameter that I pass to url not show at second portlet.
Maybe I missed something? Thanks.

code
public String generateUrl(String pageName, String portletName,
HashMap params, boolean saveState, PortletRequest request,
PortletResponse response) throws StateException, NamingException,
IOException {

final PortletStateManager mgr = getPortletStateManager(request, response);
// Get the URL factory
URLFactory urlFactory = mgr.getURLFactory();
String finalUrl = "";
try {
final EngineURL url;
if (saveState) {
url = urlFactory.newURL(Constants.SMART_COPY);
} else {
url = urlFactory.newURL(Constants.EMPTY_COPY);
}
// Set the page this URL should point to
final com.ibm.portal.state.accessors.selection.SelectionAccessorFactory selectionFactory = (com.ibm.portal.state.accessors.selection.SelectionAccessorFactory) mgr
.getAccessorFactory(com.ibm.portal.state.accessors.selection.SelectionAccessorFactory.class);
// Request the selection controller to set the page; pass in the
// state associated with the created URL
final SelectionAccessorController selectionCtrl = selectionFactory
.getSelectionAccessorController(url.getState());
// Set the page; you need the unique name (String) or the ObjectID
// of that page
selectionCtrl.setSelection(pageName);
// Dispose the accessor (avoids memory leak)
selectionCtrl.dispose();
if (portletName != null) {
// Set portlet render parameters
final PortletAccessorFactory portletAccessorFactory = (PortletAccessorFactory) mgr
.getAccessorFactory(PortletAccessorFactory.class);
// Get the portlet controller to set render parameters; pass in
// the state associated with rge created URL
final PortletAccessorController portletCtrl = portletAccessorFactory
.getPortletAccessorController(portletName, url
.getState());
// Set the render parameter
if (params != null) {
portletCtrl.getParameters().putAll(params);
}
// Dispose the accessor (avoids memory leak)
portletCtrl.dispose();
}
finalUrl = url.writeDispose(new StringWriter()).toString();
} finally {
urlFactory.dispose();
}
return finalUrl;
}
[/code]
Updated on 2013-01-21T13:33:58Z at 2013-01-21T13:33:58Z by Gobozov_Georgy
  • Gobozov_Georgy
    Gobozov_Georgy
    51 Posts

    Re: Websphere portal 8 and url generation

    ‏2013-01-21T13:33:58Z  
    Solved.

    Instead of portlet unique name just pass portlet window unique name to this method. To set portlet window unique name you need Admin - Unique Names - Pages - Page - Portlet Windows.