Search in sources :

Example 6 with ClientDataRequest

use of javax.portlet.ClientDataRequest 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 7 with ClientDataRequest

use of javax.portlet.ClientDataRequest in project liferay-faces-bridge-impl by liferay.

the class ExternalContextCompat_2_0_Impl method getRequestContentLength.

/**
 * @see    ExternalContext#getRequestContentLength()
 * @since  JSF 2.0
 */
@Override
public int getRequestContentLength() {
    int requestContentLength;
    if (portletRequest instanceof ClientDataRequest) {
        ClientDataRequest clientDataRequest = (ClientDataRequest) portletRequest;
        requestContentLength = clientDataRequest.getContentLength();
        if (manageIncongruities) {
            incongruityContext.setRequestContentLength(requestContentLength);
        }
        return requestContentLength;
    } else {
        if (manageIncongruities) {
            return incongruityContext.getRequestContentLength();
        } else {
            throw new IllegalStateException();
        }
    }
}
Also used : ClientDataRequest(javax.portlet.ClientDataRequest)

Aggregations

ClientDataRequest (javax.portlet.ClientDataRequest)7 List (java.util.List)2 Map (java.util.Map)2 ExternalContext (javax.faces.context.ExternalContext)2 ContextMapFactory (com.liferay.faces.bridge.context.map.internal.ContextMapFactory)1 UploadedFile (com.liferay.faces.bridge.model.UploadedFile)1 BridgeTest (com.liferay.faces.bridge.tck.annotation.BridgeTest)1 FacesRequestParameterMap (com.liferay.faces.util.context.map.FacesRequestParameterMap)1 MultiPartFormData (com.liferay.faces.util.context.map.MultiPartFormData)1 Product (com.liferay.faces.util.product.Product)1 ProductFactory (com.liferay.faces.util.product.ProductFactory)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 FacesException (javax.faces.FacesException)1 FacesContext (javax.faces.context.FacesContext)1 PortalContext (javax.portlet.PortalContext)1