Search in sources :

Example 11 with ProductFactory

use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-bridge-impl by liferay.

the class RenderKitBridgeImpl method getRenderer.

@Override
public Renderer getRenderer(String family, String rendererType) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
    final Product PRIMEFACES = productFactory.getProductInfo(Product.Name.PRIMEFACES);
    final boolean PRIMEFACES_DETECTED = PRIMEFACES.isDetected();
    Renderer renderer = super.getRenderer(family, rendererType);
    if (UIOutput.COMPONENT_FAMILY.equals(family)) {
        if (JAVAX_FACES_HEAD.equals(rendererType)) {
            final Product ICEFACES = productFactory.getProductInfo(Product.Name.ICEFACES);
            final boolean ICEFACES_DETECTED = ICEFACES.isDetected();
            if (ICEFACES_DETECTED) {
                renderer = new HeadRendererICEfacesImpl();
            } else if (PRIMEFACES_DETECTED) {
                renderer = new HeadRendererPrimeFacesImpl();
            } else {
                renderer = new HeadRendererBridgeImpl();
            }
        } else if (JAVAX_FACES_BODY.equals(rendererType)) {
            renderer = new BodyRendererBridgeImpl(renderer);
        } else if (RenderKitUtil.SCRIPT_RENDERER_TYPE.equals(rendererType) || RenderKitUtil.STYLESHEET_RENDERER_TYPE.equals(rendererType)) {
            renderer = new ResourceRendererBridgeImpl(renderer);
        }
    } else if (UIForm.COMPONENT_FAMILY.equals(family) && JAVAX_FACES_FORM.equals(rendererType) && PRIMEFACES_DETECTED) {
        renderer = new FormRendererPrimeFacesImpl(PRIMEFACES.getMajorVersion(), PRIMEFACES.getMinorVersion(), renderer);
    } else if (PRIMEFACES_FAMILY.equals(family) && PRIMEFACES_FILE_UPLOAD_RENDERER_TYPE.equals(rendererType)) {
        renderer = new FileUploadRendererPortletImpl(renderer);
    } else if (RICHFACES_FILE_UPLOAD_FAMILY.equals(family) && RICHFACES_FILE_UPLOAD_RENDERER_TYPE.equals(rendererType)) {
        renderer = new FileUploadRendererPortletImpl(new FileUploadRendererRichFacesImpl(renderer));
    }
    return renderer;
}
Also used : FacesContext(javax.faces.context.FacesContext) ProductFactory(com.liferay.faces.util.product.ProductFactory) FileUploadRendererPortletImpl(com.liferay.faces.bridge.renderkit.bridge.internal.FileUploadRendererPortletImpl) Product(com.liferay.faces.util.product.Product) FileUploadRendererRichFacesImpl(com.liferay.faces.bridge.renderkit.richfaces.internal.FileUploadRendererRichFacesImpl) HeadRendererICEfacesImpl(com.liferay.faces.bridge.renderkit.icefaces.internal.HeadRendererICEfacesImpl) FormRendererPrimeFacesImpl(com.liferay.faces.bridge.renderkit.primefaces.internal.FormRendererPrimeFacesImpl) ExternalContext(javax.faces.context.ExternalContext) Renderer(javax.faces.render.Renderer) HeadRendererPrimeFacesImpl(com.liferay.faces.bridge.renderkit.primefaces.internal.HeadRendererPrimeFacesImpl)

Example 12 with ProductFactory

use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-bridge-ext by liferay.

the class ResourceHandlerLiferayImpl method isJQueryPluginJSResource.

private boolean isJQueryPluginJSResource(String resourceLibrary, String resourceName) {
    FacesContext startupFacesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = startupFacesContext.getExternalContext();
    ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
    final Product BOOTSFACES = productFactory.getProductInfo(Product.Name.BOOTSFACES);
    boolean bootsFacesJQueryPluginJSResource = BOOTSFACES.isDetected() && "bsf".equals(resourceLibrary) && BOOTSFACES_JQUERY_PLUGIN_JS_RESOURCES.contains(resourceName);
    boolean butterFacesJQueryPluginJSResource = false;
    final Product BUTTERFACES = productFactory.getProductInfo(Product.Name.BUTTERFACES);
    if (BUTTERFACES.isDetected() && (resourceLibrary != null)) {
        butterFacesJQueryPluginJSResource = (resourceLibrary.equals("butterfaces-dist-bower") && BUTTERFACES_DIST_BOWER_JQUERY_PLUGIN_JS_RESOURCES.contains(resourceName)) || (resourceLibrary.equals("butterfaces-dist-bundle-js") && BUTTERFACES_DIST_BUNDLE_JS_JQUERY_PLUGIN_JS_RESOURCES.contains(resourceName)) || (resourceLibrary.equals("butterfaces-external") && BUTTERFACES_EXTERNAL_JQUERY_PLUGIN_JS_RESOURCES.contains(resourceName));
    }
    final Product PRIMEFACES = productFactory.getProductInfo(Product.Name.PRIMEFACES);
    boolean primeFacesJQueryPluginJSResource = PRIMEFACES.isDetected() && ((resourceLibrary == null) || resourceLibrary.equals("primefaces")) && PRIMEFACES_JQUERY_PLUGIN_JS_RESOURCES.contains(resourceName);
    boolean richFacesJQueryPluginJSResource = false;
    final Product RICHFACES = productFactory.getProductInfo(Product.Name.RICHFACES);
    if (RICHFACES.isDetected()) {
        boolean richfacesResourceLibrary = ("org.richfaces.resource".equals(resourceLibrary) || "org.richfaces.staticResource".equals(resourceLibrary) || "org.richfaces".equals(resourceLibrary));
        richFacesJQueryPluginJSResource = ((resourceLibrary == null) || richfacesResourceLibrary) && (resourceName.endsWith("packed.js") || resourceName.endsWith("jquery.js"));
    }
    return (bootsFacesJQueryPluginJSResource || butterFacesJQueryPluginJSResource || primeFacesJQueryPluginJSResource || richFacesJQueryPluginJSResource);
}
Also used : FacesContext(javax.faces.context.FacesContext) ProductFactory(com.liferay.faces.util.product.ProductFactory) ExternalContext(javax.faces.context.ExternalContext) Product(com.liferay.faces.util.product.Product)

Example 13 with ProductFactory

use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-bridge-ext by liferay.

the class PortletRequestDispatcherBridgeLiferayImpl method include.

@Override
public void include(PortletRequest portletRequest, PortletResponse portletResponse) throws PortletException, IOException {
    boolean unwrapRequest = false;
    PortletSession portletSession = portletRequest.getPortletSession();
    PortletContext portletContext = portletSession.getPortletContext();
    ProductFactory productFactory = (ProductFactory) BridgeFactoryFinder.getFactory(portletContext, ProductFactory.class);
    final Product LIFERAY_PORTAL = productFactory.getProductInfo(Product.Name.LIFERAY_PORTAL);
    final int LIFERAY_PORTAL_MAJOR_VERSION = LIFERAY_PORTAL.getMajorVersion();
    // For more info, see https://issues.liferay.com/browse/LPS-3311
    if (LIFERAY_PORTAL_MAJOR_VERSION < 6) {
        unwrapRequest = true;
    } else // https://github.com/liferay/liferay-portal/commit/093dabbb252e2bba5404cddbcb600d787ef0b010
    if (LIFERAY_PORTAL_MAJOR_VERSION == 6) {
        final int LIFERAY_PORTAL_MINOR_VERSION = LIFERAY_PORTAL.getMinorVersion();
        if (LIFERAY_PORTAL_MINOR_VERSION == 0) {
            unwrapRequest = true;
        } else if (LIFERAY_PORTAL_MINOR_VERSION == 1) {
            final int LIFERAY_PORTAL_PATCH_VERSION = LIFERAY_PORTAL.getPatchVersion();
            // CE
            if (LIFERAY_PORTAL_PATCH_VERSION < 10) {
                unwrapRequest = (LIFERAY_PORTAL_PATCH_VERSION < 2);
            } else // EE
            if (LIFERAY_PORTAL_PATCH_VERSION < 30) {
                unwrapRequest = true;
            }
        }
    }
    if (unwrapRequest) {
        portletRequest = unwrapPortletRequest(portletRequest);
    }
    // PortletResponseWrapper.
    if ((portletResponse instanceof HttpServletResponseWrapper) || (portletResponse instanceof PortletResponseWrapper)) {
        portletResponse = unwrapPortletResponse(portletResponse);
    }
    super.include(portletRequest, portletResponse);
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory) PortletSession(javax.portlet.PortletSession) HttpServletResponseWrapper(javax.servlet.http.HttpServletResponseWrapper) Product(com.liferay.faces.util.product.Product) PortletContext(javax.portlet.PortletContext) PortletResponseWrapper(javax.portlet.filter.PortletResponseWrapper)

Example 14 with ProductFactory

use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-bridge-ext by liferay.

the class BridgeExtDependencyVerifier method verify.

public static void verify(ExternalContext externalContext) {
    ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
    final Product LIFERAY_PORTAL = productFactory.getProductInfo(Product.Name.LIFERAY_PORTAL);
    Package bridgeExtPackage = BridgeExtDependencyVerifier.class.getPackage();
    String implementationTitle = bridgeExtPackage.getImplementationTitle();
    String implementationVersion = bridgeExtPackage.getImplementationVersion();
    final int LIFERAY_PORTAL_MAJOR_VERSION = LIFERAY_PORTAL.getMajorVersion();
    final int LIFERAY_PORTAL_MINOR_VERSION = LIFERAY_PORTAL.getMinorVersion();
    if (!((LIFERAY_PORTAL_MAJOR_VERSION == 7) && (LIFERAY_PORTAL_MINOR_VERSION >= 2))) {
        logger.error("{0} {1} is designed to be used with Liferay Portal 7.2+ but detected {2}.{3}", implementationTitle, implementationVersion, LIFERAY_PORTAL_MAJOR_VERSION, LIFERAY_PORTAL_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);
    }
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory) Product(com.liferay.faces.util.product.Product)

Aggregations

ProductFactory (com.liferay.faces.util.product.ProductFactory)14 Product (com.liferay.faces.util.product.Product)12 ExternalContext (javax.faces.context.ExternalContext)5 PortletContext (javax.portlet.PortletContext)4 FacesRequestParameterMap (com.liferay.faces.util.context.map.FacesRequestParameterMap)2 MultiPartFormData (com.liferay.faces.util.context.map.MultiPartFormData)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 FacesContext (javax.faces.context.FacesContext)2 PortletSession (javax.portlet.PortletSession)2 PortletContextAdapter (com.liferay.faces.bridge.context.internal.PortletContextAdapter)1 HeaderRequestHttpServletAdapter (com.liferay.faces.bridge.filter.internal.HeaderRequestHttpServletAdapter)1 HeaderResponseHttpServletAdapter (com.liferay.faces.bridge.filter.internal.HeaderResponseHttpServletAdapter)1 ResourceRequestHttpServletAdapter (com.liferay.faces.bridge.filter.internal.ResourceRequestHttpServletAdapter)1 ResourceResponseHttpServletAdapter (com.liferay.faces.bridge.filter.internal.ResourceResponseHttpServletAdapter)1 UploadedFile (com.liferay.faces.bridge.model.UploadedFile)1 UploadedFileBridgeImpl (com.liferay.faces.bridge.model.internal.UploadedFileBridgeImpl)1 FileUploadRendererPortletImpl (com.liferay.faces.bridge.renderkit.bridge.internal.FileUploadRendererPortletImpl)1 HeadRendererICEfacesImpl (com.liferay.faces.bridge.renderkit.icefaces.internal.HeadRendererICEfacesImpl)1 FormRendererPrimeFacesImpl (com.liferay.faces.bridge.renderkit.primefaces.internal.FormRendererPrimeFacesImpl)1