public Text generateRenderMarkup(PortletInvocationResponse pir, WebuiRequestContext context) {
PortalRequestContext prcontext = (PortalRequestContext) context;
Text markup = null;
if (pir instanceof FragmentResponse) {
JavascriptManager jsMan = context.getJavascriptManager();
jsMan.loadScriptResource(ResourceScope.PORTLET, getApplicationId());
FragmentResponse fragmentResponse = (FragmentResponse) pir;
switch (fragmentResponse.getType()) {
case FragmentResponse.TYPE_CHARS:
markup = Text.create(fragmentResponse.getContent());
break;
case FragmentResponse.TYPE_BYTES:
markup = Text.create(fragmentResponse.getBytes(), Charset.forName("UTF-8"));
break;
case FragmentResponse.TYPE_EMPTY:
markup = Text.create("");
break;
}
setConfiguredTitle(fragmentResponse.getTitle());
// setup portlet properties
if (fragmentResponse.getProperties() != null) {
// setup transport headers
if (fragmentResponse.getProperties().getTransportHeaders() != null) {
MultiValuedPropertyMap<String> transportHeaders = fragmentResponse.getProperties().getTransportHeaders();
for (String key : transportHeaders.keySet()) {
if (JAVASCRIPT_DEPENDENCY.equals(key)) {
for (String value : transportHeaders.getValues(key)) {
jsMan.require(value);
}
} else {
for (String value : transportHeaders.getValues(key)) {
prcontext.getResponse().setHeader(key, value);
}