Calling a Portlet From a Portlet

Frank 30.04.2014

A portlet calls another portlet that is placed on a different page. The calling portlet generates a URL in the associated processAction method and sets a parameter to be transmitted. The generated URL will appear as a link on the JSP page of the calling portlet. If the link is clicked, the other portlet is called and its processAction method reads the parameter.

Requirements:

* the portlets must be deployed on the portal server.
* the page that contains the calling portlet und the portlet that is to be called, must have a unique name.

Implementation with parameters

URL generator

private String PAGENAME = "de.example.test";
private String PORTLETNAME = "de.example.portlet.receiver";
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, java.io.IOException {
     String url = "";
     try {
          GenericPortletURLHelper portletHelper =
          UrlHelperFactory.getPortletURLHelper(FactoryConstants.PortalVersion70);
          String value = request.getParameter("value");
          HashMap map = new HashMap();
          String[] value1 = {value};
          map.put("testPara1", value1);
          url = portletHelper.generateUrl(PAGENAME, PORTLETNAME, map, request,
               response);
     } catch (Exception e) {
          System.out.println("!!!!ERROR: " + e.getMessage());
     }
     request.getPortletSession().setAttribute("url", url);
}

Receiver

public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, java.io.IOException {
     String value = request.getParameter("testPara1“);
 ...
}

 

Lernen Sie mehr über:

WebSphere Application Server

WebSphere Portal Server

IBM DataPower

IBM BPM | Process Server

IBM LDAP

Interessantes

Calling a Portal Page From a Servlet

Frank 30.04.2014

There are many situations in which a servlet has to generate a URL for a portal page. Examples are the generation of a URL on request of a servlet and sending this URL by e-mail, the connection of external systems and jumps to certain portal pages, etc. Requirements: * The servlet must be deployed on […]

Über Uns

Unsere Arbeit

Unsere Partner

Unser Blog

IBM Produkte

Software Engineering

IT Architecture

Workshops

Unternehmen

Produkte

Services

Lösungen