use of com.liferay.faces.util.product.Product in project liferay-faces-bridge-impl by liferay.
the class PreDestroyInvokerFactoryImpl method getPreDestroyInvoker.
@Override
public PreDestroyInvoker getPreDestroyInvoker(ServletContext servletContext) {
PortletContextAdapter portletContextAdapter = new PortletContextAdapter(servletContext);
ProductFactory productFactory = (ProductFactory) BridgeFactoryFinder.getFactory(portletContextAdapter, ProductFactory.class);
final Product MOJARRA = productFactory.getProductInfo(Product.Name.MOJARRA);
if (MOJARRA.isDetected()) {
return new PreDestroyInvokerMojarraImpl(servletContext);
} else {
return new PreDestroyInvokerImpl();
}
}
use of com.liferay.faces.util.product.Product in project liferay-faces-bridge-impl by liferay.
the class ResourceHandlerRichfacesImpl method createResource.
private Resource createResource(String resourceName, Resource resource) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
final Product RICHFACES = ProductFactory.getProductInstance(externalContext, Product.Name.RICHFACES);
final boolean RICHFACES_DETECTED = RICHFACES.isDetected();
if ((resource != null) && RICHFACES_DETECTED) {
// If this is a RichFaces static css resource, then return a filtered Richfaces static CSS resource.
if (resourceName.startsWith(RICHFACES_STATIC_RESOURCE) && resourceName.endsWith(".css")) {
resource = new ResourceRichFacesCSSImpl(resource);
} else // resource.
if (resourceName.startsWith(RICHFACES_STATIC_RESOURCE) && resourceName.endsWith("packed.js")) {
resource = new ResourceRichFacesPackedJSImpl(resource);
} else if (resource.getClass().getName().startsWith(ORG_RICHFACES_RESOURCE)) {
resource = new ResourceRichFacesImpl(resource);
}
}
return resource;
}
use of com.liferay.faces.util.product.Product in project liferay-faces-bridge-impl by liferay.
the class ExceptionHandlerFactoryBridgeImpl method getExceptionHandler.
@Override
public ExceptionHandler getExceptionHandler() {
ExceptionHandler wrappedExceptionHandler = wrappedExceptionHandlerFactory.getExceptionHandler();
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
Product ICEFACES = ProductFactory.getProductInstance(externalContext, Product.Name.ICEFACES);
final int MAJOR_VERSION = ICEFACES.getMajorVersion();
if (ICEFACES.isDetected() && (((MAJOR_VERSION == 4) && (ICEFACES.getMinorVersion() < 2)) || (MAJOR_VERSION < 4))) {
// Workaround for https://issues.liferay.com/browse/FACES-3012
facesContext.getPartialViewContext();
}
return new ExceptionHandlerBridgeImpl(wrappedExceptionHandler);
}
use of com.liferay.faces.util.product.Product in project liferay-faces-bridge-impl by liferay.
the class BridgeDependencyVerifier method verify.
public static void verify(ExternalContext externalContext) {
Package bridgePackage = BridgeDependencyVerifier.class.getPackage();
String implementationTitle = bridgePackage.getImplementationTitle();
String implementationVersion = bridgePackage.getImplementationVersion();
ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
final Product LIFERAY_PORTAL = productFactory.getProductInfo(Product.Name.LIFERAY_PORTAL);
if (LIFERAY_PORTAL.isDetected()) {
final Product LIFERAY_FACES_BRIDGE_EXT = productFactory.getProductInfo(Product.Name.LIFERAY_FACES_BRIDGE_EXT);
if (!LIFERAY_FACES_BRIDGE_EXT.isDetected()) {
logger.error("{0} {1} is running in Liferay Portal {2}.{3} but the com.liferay.faces.bridge.ext.jar dependency is not in the classpath", implementationTitle, implementationVersion, LIFERAY_PORTAL.getMajorVersion(), LIFERAY_PORTAL.getMinorVersion());
}
}
final Product PORTLET_API = productFactory.getProductInfo(Product.Name.PORTLET_API);
final int PORTLET_API_MAJOR_VERSION = PORTLET_API.getMajorVersion();
final int PORTLET_API_MINOR_VERSION = PORTLET_API.getMinorVersion();
if (!((PORTLET_API_MAJOR_VERSION > 3) || ((PORTLET_API_MAJOR_VERSION == 3) && (PORTLET_API_MINOR_VERSION >= 0)))) {
logger.error("{0} {1} is designed to be used with Portlet 3.0+ but detected {2}.{3}", implementationTitle, implementationVersion, PORTLET_API_MAJOR_VERSION, PORTLET_API_MINOR_VERSION);
}
final Product JSF = productFactory.getProductInfo(Product.Name.JSF);
final int JSF_MAJOR_VERSION = JSF.getMajorVersion();
final int JSF_MINOR_VERSION = JSF.getMinorVersion();
if (!((JSF_MAJOR_VERSION == 2) && (JSF_MINOR_VERSION == 3))) {
logger.error("{0} {1} is designed to be used with JSF 2.3 but detected {2}.{3}", implementationTitle, implementationVersion, JSF_MAJOR_VERSION, JSF_MINOR_VERSION);
}
String lsv485PatchVersion = externalContext.getInitParameter("com.liferay.faces.lsv.485.patch.version");
if ((lsv485PatchVersion != null) && !lsv485PatchVersion.equals("")) {
logger.error("{0} {1} contains fixes for LSV-485 so it is incompatible with com.liferay.faces.lsv.485.patch.jar. Please remove com.liferay.faces.lsv.485.patch.jar from the classpath.", implementationTitle, implementationVersion);
}
}
use of com.liferay.faces.util.product.Product in project liferay-faces-bridge-impl by liferay.
the class BodyRendererBridgeImpl method encodeBegin.
/**
* It is forbidden for a portlet to render the &<body&> element, so instead, render a
* &<div&>element.
*
* @see Renderer#encodeBegin(FacesContext, UIComponent)
*/
@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException {
ResponseWriter originalResponseWriter = facesContext.getResponseWriter();
ResponseWriter responseWriter = new ResponseWriterBridgeBodyImpl(originalResponseWriter);
facesContext.setResponseWriter(responseWriter);
super.encodeBegin(facesContext, uiComponent);
PortletNamingContainerUIViewRoot viewRoot = (PortletNamingContainerUIViewRoot) facesContext.getViewRoot();
String clientId = viewRoot.getContainerClientId(facesContext);
responseWriter.writeAttribute("id", clientId, null);
String styleClass = (String) uiComponent.getAttributes().get("styleClass");
// ResponseWriterBridgeBodyImpl will append STYLE_CLASS_PORTLET_BODY to the specified styleClass.
if (styleClass == null) {
responseWriter.writeAttribute("class", RenderKitUtil.STYLE_CLASS_PORTLET_BODY, "styleClass");
}
// Render each of the head resources that were not renderable in the head section into the top of the portlet
// body (the outer <div> of the portlet markup). This happens when the portlet container may not support adding
// resources to the <head> section. For example, Pluto does not support the feature of adding resources to the
// <head> section. Liferay supports it with the exception of "runtime" and WSRP portlets. See
// PortalContextBridgeImpl and PortalContextBridgeLiferayImpl (in bridge-ext) for more information. Script
// resources are rendered at the top of the portlet body instead of the bottom because elements and scripts in
// the portlet body may depend on these resources (for example jquery.js), so head resource scripts must be
// loaded before the portlet body is rendered.
Map<Object, Object> facesContextAttributes = facesContext.getAttributes();
List<UIComponent> headResourcesToRenderInBody = (List<UIComponent>) facesContextAttributes.get(RenderKitUtil.HEAD_RESOURCES_TO_RENDER_IN_BODY);
Set<String> headResourceIds = RenderKitUtil.getHeadResourceIds(facesContext);
// https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
if (headResourcesToRenderInBody != null) {
ExternalContext externalContext = facesContext.getExternalContext();
final Product BOOTSFACES = ProductFactory.getProductInstance(externalContext, Product.Name.BOOTSFACES);
final boolean BOOTSFACES_DETECTED = BOOTSFACES.isDetected();
for (UIComponent headResource : headResourcesToRenderInBody) {
headResource.encodeAll(facesContext);
// tracked as if they were rendered in the <head> section so that they are not loaded multiple times.
if (RenderKitUtil.isScriptResource(headResource, BOOTSFACES_DETECTED)) {
headResourceIds.add(ResourceUtil.getResourceId(headResource));
}
}
}
facesContext.setResponseWriter(originalResponseWriter);
}
Aggregations