Search in sources :

Example 6 with ProductFactory

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

the class ContextMapFactoryImpl method getUploadedFileMap.

@Override
public Map<String, List<UploadedFile>> getUploadedFileMap(PortletRequest portletRequest) {
    Map<String, List<UploadedFile>> bridgeUploadedFileMap = Collections.emptyMap();
    MultiPartFormData multiPartFormData = (MultiPartFormData) portletRequest.getAttribute(MULTIPART_FORM_DATA_FQCN);
    if (multiPartFormData != null) {
        Map<String, List<com.liferay.faces.util.model.UploadedFile>> uploadedFileMap = multiPartFormData.getUploadedFileMap();
        if (uploadedFileMap != null) {
            PortletSession portletSession = portletRequest.getPortletSession(true);
            PortletContext portletContext = portletSession.getPortletContext();
            Map<String, Object> applicationScopeMap = getApplicationScopeMap(portletContext, true);
            ExternalContext externalContext = new ExternalContextProductImpl(applicationScopeMap);
            ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
            Product PRIMEFACES = productFactory.getProductInfo(Product.Name.PRIMEFACES);
            boolean primeFacesDetected = PRIMEFACES.isDetected();
            int primeFacesMajorVersion = PRIMEFACES.getMajorVersion();
            bridgeUploadedFileMap = new HashMap<String, List<UploadedFile>>(uploadedFileMap.size());
            Set<Map.Entry<String, List<com.liferay.faces.util.model.UploadedFile>>> entrySet = uploadedFileMap.entrySet();
            for (Map.Entry<String, List<com.liferay.faces.util.model.UploadedFile>> mapEntry : entrySet) {
                List<com.liferay.faces.util.model.UploadedFile> uploadedFileList = mapEntry.getValue();
                if (uploadedFileList != null) {
                    List<UploadedFile> bridgeUploadedFileList = new ArrayList<UploadedFile>(uploadedFileList.size());
                    for (com.liferay.faces.util.model.UploadedFile uploadedFile : uploadedFileList) {
                        bridgeUploadedFileList.add(new UploadedFileBridgeImpl(uploadedFile, primeFacesDetected, primeFacesMajorVersion));
                    }
                    bridgeUploadedFileMap.put(mapEntry.getKey(), bridgeUploadedFileList);
                }
            }
        }
    }
    return bridgeUploadedFileMap;
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory) ArrayList(java.util.ArrayList) Product(com.liferay.faces.util.product.Product) UploadedFileBridgeImpl(com.liferay.faces.bridge.model.internal.UploadedFileBridgeImpl) ExternalContext(javax.faces.context.ExternalContext) ArrayList(java.util.ArrayList) List(java.util.List) MultiPartFormData(com.liferay.faces.util.context.map.MultiPartFormData) UploadedFile(com.liferay.faces.bridge.model.UploadedFile) PortletSession(javax.portlet.PortletSession) PortletContext(javax.portlet.PortletContext) HashMap(java.util.HashMap) Map(java.util.Map) FacesRequestParameterMap(com.liferay.faces.util.context.map.FacesRequestParameterMap)

Example 7 with ProductFactory

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

the class ContextMapFactoryImpl method getFacesRequestParameterMap.

protected FacesRequestParameterMap getFacesRequestParameterMap(PortletRequest portletRequest, String responseNamespace, PortletConfig portletConfig, BridgeRequestScope bridgeRequestScope, String defaultRenderKitId, String facesViewQueryString) {
    FacesRequestParameterMap facesRequestParameterMap = null;
    Map<String, String> facesViewParameterMap = getFacesViewParameterMap(facesViewQueryString);
    PortalContext portalContext = portletRequest.getPortalContext();
    boolean strictParameterNamespacingSupported = FacesRuntimeUtil.isStrictParameterNamespacingSupported(portalContext);
    PortletContext portletContext = portletConfig.getPortletContext();
    boolean namespaceViewState = strictParameterNamespacingSupported && FacesRuntimeUtil.isNamespaceViewState(strictParameterNamespacingSupported, portletContext);
    if (portletRequest instanceof ClientDataRequest) {
        ClientDataRequest clientDataRequest = (ClientDataRequest) portletRequest;
        String contentType = clientDataRequest.getContentType();
        // Note: af:inputFile (ADF Faces) ace:fileEntry (ICEfaces) rely on their own mechanisms for handling file
        // uploads.
        ProductFactory productFactory = (ProductFactory) BridgeFactoryFinder.getFactory(portletContext, ProductFactory.class);
        Product ADF_FACES_RICH_CLIENT = productFactory.getProductInfo(Product.Name.ADF_FACES);
        Product ICEFACES = productFactory.getProductInfo(Product.Name.ICEFACES);
        if (!ADF_FACES_RICH_CLIENT.isDetected() && !ICEFACES.isDetected() && (contentType != null) && contentType.toLowerCase().startsWith("multipart/")) {
            MultiPartFormData multiPartFormData = (MultiPartFormData) portletRequest.getAttribute(MULTIPART_FORM_DATA_FQCN);
            if (multiPartFormData == null) {
                facesRequestParameterMap = new FacesRequestParameterMapImpl(responseNamespace, bridgeRequestScope, facesViewParameterMap, defaultRenderKitId, getSeparatorChar(), strictParameterNamespacingSupported, namespaceViewState);
                MultiPartFormDataProcessor multiPartFormDataProcessor = new MultiPartFormDataProcessorImpl();
                Map<String, List<com.liferay.faces.util.model.UploadedFile>> uploadedFileMap = multiPartFormDataProcessor.process(clientDataRequest, portletConfig, facesRequestParameterMap);
                multiPartFormData = new MultiPartFormDataImpl(facesRequestParameterMap, uploadedFileMap);
                // Save the multipart/form-data in a request attribute so that it can be referenced later-on in the
                // JSF lifecycle by file upload component renderers.
                portletRequest.setAttribute(MULTIPART_FORM_DATA_FQCN, multiPartFormData);
            } else {
                facesRequestParameterMap = multiPartFormData.getFacesRequestParameterMap();
            }
        }
    }
    if (facesRequestParameterMap == null) {
        Map<String, String[]> parameterMap = portletRequest.getParameterMap();
        facesRequestParameterMap = new FacesRequestParameterMapImpl(parameterMap, responseNamespace, bridgeRequestScope, facesViewParameterMap, defaultRenderKitId, getSeparatorChar(), strictParameterNamespacingSupported, namespaceViewState);
    }
    return facesRequestParameterMap;
}
Also used : FacesRequestParameterMap(com.liferay.faces.util.context.map.FacesRequestParameterMap) ClientDataRequest(javax.portlet.ClientDataRequest) ProductFactory(com.liferay.faces.util.product.ProductFactory) Product(com.liferay.faces.util.product.Product) PortalContext(javax.portlet.PortalContext) PortletContext(javax.portlet.PortletContext) MultiPartFormData(com.liferay.faces.util.context.map.MultiPartFormData) ArrayList(java.util.ArrayList) List(java.util.List)

Example 8 with ProductFactory

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

the class PreDestroyInvokerFactoryImpl method getPreDestroyInvoker.

@Override
public PreDestroyInvoker getPreDestroyInvoker(PortletContext portletContext) {
    ProductFactory productFactory = (ProductFactory) BridgeFactoryFinder.getFactory(portletContext, ProductFactory.class);
    final Product MOJARRA = productFactory.getProductInfo(Product.Name.MOJARRA);
    if (MOJARRA.isDetected()) {
        return new PreDestroyInvokerMojarraImpl(portletContext);
    } else {
        return new PreDestroyInvokerImpl();
    }
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory) Product(com.liferay.faces.util.product.Product)

Example 9 with ProductFactory

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

the class FacesRuntimeUtil method isAbleToNamespaceViewState.

public static boolean isAbleToNamespaceViewState(PortalContext portalContext, ExternalContext externalContext) {
    Boolean namespacedViewStateSupported = false;
    if (isStrictParameterNamespacingSupported(portalContext)) {
        Map<String, Object> applicationMap = externalContext.getApplicationMap();
        namespacedViewStateSupported = (Boolean) applicationMap.get(FacesRuntimeUtil.class.getName());
        if (namespacedViewStateSupported == null) {
            ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
            namespacedViewStateSupported = isNamespacedViewStateSupported(productFactory);
        }
    }
    return namespacedViewStateSupported;
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory)

Example 10 with ProductFactory

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

the class FacesRuntimeUtil method isNamespaceViewState.

public static boolean isNamespaceViewState(boolean strictParameterNamespacingSupported, PortletContext portletContext) {
    Boolean namespacedViewStateSupported = false;
    if (strictParameterNamespacingSupported) {
        namespacedViewStateSupported = (Boolean) portletContext.getAttribute(FacesRuntimeUtil.class.getName());
        if (namespacedViewStateSupported == null) {
            ProductFactory productFactory = (ProductFactory) BridgeFactoryFinder.getFactory(portletContext, ProductFactory.class);
            namespacedViewStateSupported = isNamespacedViewStateSupported(productFactory);
        }
    }
    return namespacedViewStateSupported;
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory)

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