use of com.liferay.faces.bridge.filter.internal.ResourceRequestHttpServletAdapter in project liferay-faces-bridge-impl by liferay.
the class ViewDeclarationLanguageBridgeJspImpl method buildView.
@Override
public void buildView(FacesContext facesContext, UIViewRoot uiViewRoot) throws IOException {
ExternalContext externalContext = facesContext.getExternalContext();
ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
final Product MYFACES = productFactory.getProductInfo(Product.Name.MYFACES);
final boolean MYFACES_DETECTED = MYFACES.isDetected();
PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
PortletResponse portletResponse = (PortletResponse) externalContext.getResponse();
// adapter that implements HttpServletRequest.
if (MYFACES_DETECTED) {
if (portletRequest instanceof HeaderRequest) {
String requestCharacterEncoding = externalContext.getRequestCharacterEncoding();
externalContext.setRequest(new HeaderRequestHttpServletAdapter((HeaderRequest) portletRequest, requestCharacterEncoding));
} else if (portletRequest instanceof ResourceRequest) {
externalContext.setRequest(new ResourceRequestHttpServletAdapter((ResourceRequest) portletRequest));
}
}
final Product MOJARRA = productFactory.getProductInfo(Product.Name.MOJARRA);
final boolean MOJARRA_DETECTED = MOJARRA.isDetected();
// PortletResponse with an adapter that implements HttpServletResponse.
if (MOJARRA_DETECTED || MYFACES_DETECTED) {
if (portletResponse instanceof HeaderResponse) {
externalContext.setResponse(new HeaderResponseHttpServletAdapter((HeaderResponse) portletResponse));
} else if (portletResponse instanceof ResourceResponse) {
externalContext.setResponse(new ResourceResponseHttpServletAdapter((ResourceResponse) portletResponse));
}
}
// Delegate
super.buildView(facesContext, uiViewRoot);
// If Mojarra or MyFaces is detected, then un-decorate the PortletRequest.
if (MOJARRA_DETECTED || MYFACES_DETECTED) {
externalContext.setResponse(portletResponse);
}
// If MyFaces is detected, then un-decorate the PortletResponse.
if (MYFACES_DETECTED) {
externalContext.setRequest(portletRequest);
}
}
Aggregations