WebSphere Issues


When rendering a JSP component with the JSR286 rendering portlet

Filed under: WCM, WebSphere Portal — Ishtiaque @ 10:29 am

When rendering JSP components through the JSR286 local rendering portlet you need to check the Workspace.WCM_RENDERINGCONTEXT_KEY attribute on the original PortletRequest.

There are 2 ways to achieve that:

1. Import the JSR Portlet JSP Tag lib and get the RenderingContext from the renderRequest object.
This approach is more elegant but it will only work when rendering via the JSR286 rendering.

<%@ taglib uri=”http://java.sun.com/portlet&#8221; prefix=”portlet” %>
RenderingContext renderingCtx = request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);
if(renderingCtx == null) {
renderingCtx = (RenderingContext)renderRequest.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);

2. Get the PortletRequest from the ServletRequest as documented in the Java Portlet 2.0 Specification.
This works for rendering via the both (legacy and JSR286) rendering portlets and also for servlet rendering.

<%@ page import=”javax.portlet.*”%>
RenderingContext renderingCtx = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);
if(renderingCtx == null) {
Object portletRequest = request.getAttribute(“javax.portlet.request”);
if(portletRequest != null && portletRequest instanceof PortletRequest) {
// JSR286 rendering
renderingCtx = (RenderingContext) ((PortletRequest)portletRequest).




Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: