StringBuilder portletContent = new StringBuilder();
try
{
PortalRequestContext prcontext = (PortalRequestContext)WebuiRequestContext.getCurrentInstance();
prcontext.setFullRender(true);
StatefulPortletContext portletContext = uiPortlet_.getPortletContext();
ExoPortletInvocationContext portletInvocationContext = new ExoPortletInvocationContext(prcontext, uiPortlet_);
List<Cookie> requestCookies = new ArrayList<Cookie>(Arrays.asList(prcontext.getRequest().getCookies()));
RenderInvocation renderInvocation = new RenderInvocation(portletInvocationContext);
renderInvocation.setClientContext(new AbstractClientContext(prcontext.getRequest(), requestCookies));
renderInvocation.setServerContext(new AbstractServerContext(prcontext.getRequest(), prcontext.getResponse()));
// instance context
InstanceContext instanceContext;
if (portletContext.getType() instanceof WSRPPortletStateType)
{
WSRP wsrp = (WSRP)portletContext.getState();
AccessMode accessMode = AccessMode.CLONE_BEFORE_WRITE;
if (wsrp.isCloned())
{
accessMode = AccessMode.READ_WRITE;
}
instanceContext = new ExoPortletInstanceContext(wsrp.getPortletId(), accessMode);
}
else
{
ExoPortletState exo = (ExoPortletState)portletContext.getState();
instanceContext = new ExoPortletInstanceContext(exo.getPortletId());
}
renderInvocation.setInstanceContext(instanceContext);
renderInvocation.setUserContext(new AbstractUserContext(prcontext.getRequest()));