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);
}
}
}
}
// setup up portlet cookies
if (fragmentResponse.getProperties().getCookies() != null) {
List<Cookie> cookies = fragmentResponse.getProperties().getCookies();
for (Cookie cookie : cookies) {
prcontext.getResponse().addCookie(cookie);
}
}
// setup markup headers
if (fragmentResponse.getProperties().getMarkupHeaders() != null) {
MultiValuedPropertyMap<Element> markupHeaders = fragmentResponse.getProperties().getMarkupHeaders();
List<Element> markupElements = markupHeaders.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
if (markupElements != null) {
for (Element element : markupElements) {
if (!context.useAjax() && "title".equals(element.getNodeName().toLowerCase())