HttpServletRequest httpServletRequest = getHttpServletRequest(portletRequest);
PortletResponse portletResponse = (PortletResponse) externalContext.getResponse();
HttpServletResponse httpServletResponse = getHttpServletResponse(portletResponse);
ELContext elContext = facesContext.getELContext();
StringJspWriter stringJspWriter = new StringJspWriter();
PageContextAdapter pageContextAdapter = new PageContextAdapter(httpServletRequest, httpServletResponse,
elContext, stringJspWriter);
// Invoke the JSP tag lifecycle directly (rather than using the tag from a JSP).
tag.setPageContext(pageContextAdapter);
tag.doStartTag();
tag.doEndTag();
// If executing within an Ajax request, then write all the scripts contained in the AUI_SCRIPT_DATA attribute
// directly to the tag output.
PartialViewContext partialViewContext = facesContext.getPartialViewContext();
if (partialViewContext.isAjaxRequest()) {
//J-
// TODO: Possibly need to be concerned about inline scripts written in the <head>...</head> section during Ajax.
//
// StringBundler data = HtmlTopTag.getData(httpServletRequest, WebKeys.PAGE_TOP);
//J+
Object scriptData = httpServletRequest.getAttribute(WebKeys.AUI_SCRIPT_DATA);
if (scriptData != null) {
JspWriter jspWriter = pageContextAdapter.getOut();
try {
jspWriter.write(portalTagOutputParser.getScriptSectionMarker());
ScriptTagUtil.flushScriptData(pageContextAdapter);
}