// Retrieve the portlet window config for the evaluated portlet ID.
ServletContext servletContext = pageContext.getServletContext();
DriverConfiguration driverConfig = (DriverConfiguration)
servletContext.getAttribute(AttributeKeys.DRIVER_CONFIG);
PortletWindowConfig windowConfig = driverConfig
.getPortletWindowConfig(evaluatedPortletId);
if (isPortletModeAllowed(driverConfig, windowConfig, portletMode)) {
// Retrieve the portal environment.
PortalRequestContext portalEnv = PortalRequestContext.getContext(