Examples of AddResource


Examples of org.apache.myfaces.renderkit.html.util.AddResource

            //Object extendedRequest = portletRequest;
            //Object extendedResponse = portletResponse;
           
            //boolean multipartContent = false;           
           
            AddResource addResource= AddResourceFactory.getInstance(this);
            addResource.responseStarted();

            if (addResource.requiresBuffer())
            {
                throw new IllegalStateException("buffering not supported in the portal environment. "+
                        " Use for org.apache.myfaces.ADD_RESOURCE_CLASS the value"+
                        " org.apache.myfaces.renderkit.html.util.NonBufferingAddResource.");
            }
           
            //externalContextDelegate = new PortletExternalContextWrapper(
            //        delegate.getExternalContext(), extendedRequest, extendedResponse, multipartContent);
        }
        else {
            HttpServletResponse httpResponse = (HttpServletResponse) delegate.getExternalContext().getResponse();
            HttpServletRequest httpRequest = (HttpServletRequest) delegate.getExternalContext().getRequest();

            HttpServletRequest extendedRequest = httpRequest;

            // For multipart/form-data requests we need to encapsulate
            // the request using MultipartRequestWrapper. This could not be
            // done on TomahawkFacesContextFactory.getFacesContext(...)
            // because we need an ExternalContext instance to get
            // the init params for the ExtensionsFilter and initialize
            // MultipartRequestWrapper with the correct values.
           
            boolean multipartContent = false;
          
            if (FileUpload.isMultipartContent(httpRequest)) {
                multipartContent = true;
               
                MultipartRequestWrapperConfig config = MultipartRequestWrapperConfig
                        .getMultipartRequestWrapperConfig(delegate
                                .getExternalContext());               
               
                extendedRequest = new MultipartRequestWrapper(httpRequest, config.getUploadMaxFileSize(),
                        config.getUploadThresholdSize(), config.getUploadRepositoryPath());
               
            }

            AddResource addResource= AddResourceFactory.getInstance(this);
            addResource.responseStarted();

            if (addResource.requiresBuffer() && extensionsResponseWrapper != null)
            {
                //If the request requires buffer, this was already
                //wrapped (on TomahawkFacesContextFactory.getFacesContext(...) ),
                //but we need to save the wrapped response value
                //on a local variable to then reference it on release()
View Full Code Here

Examples of org.apache.myfaces.renderkit.html.util.AddResource

        delegate.addMessage(clientId, message);
    }

    public void release() {

        AddResource addResource=null;

        try
        {
            addResource= AddResourceFactory.getInstance(this);
            if (addResource.requiresBuffer())
            {
                if(extensionsResponseWrapper == null) {
                    throw new NullPointerException("When wrapping the faces-context, add-resource told us that no buffer is required, " +
                            "now it is required, and we have a null-extensionsResponseWrapper. Please fix add-resource to be consistent over a single request.");
                }
                extensionsResponseWrapper.finishResponse();

                // write the javascript stuff for myfaces and headerInfo, if needed
                HttpServletResponse servletResponse = extensionsResponseWrapper.getDelegate();
                HttpServletRequest servletRequest = (HttpServletRequest) getExternalContext().getRequest();

                String contentType = extensionsResponseWrapper.getContentType();
               
                // only parse HTML responses
                if (contentType != null && isValidContentType(contentType))
                {
                    String oldResponse = extensionsResponseWrapper.toString();
                    addResource.parseResponse(servletRequest, extensionsResponseWrapper.toString(),
                            servletResponse);

                    addResource.writeMyFacesJavascriptBeforeBodyEnd(servletRequest,
                            servletResponse);

                    if( ! addResource.hasHeaderBeginInfos() ){
                        // writes the response if no header info is needed
                        addResource.writeResponse(servletRequest, servletResponse);
                        return;
                    }

                    // Some headerInfo has to be added
                    addResource.writeWithFullHeader(servletRequest, servletResponse);

                    // writes the response
                    addResource.writeResponse(servletRequest, servletResponse);
                }
                else
                {

                    byte[] responseArray = extensionsResponseWrapper.getBytes();

                    if(responseArray.length > 0)
                    {
                         // When not filtering due to not valid content-type, deliver the byte-array instead of a charset-converted string.
                         // Otherwise a binary stream gets corrupted.
                         servletResponse.getOutputStream().write(responseArray);
                     }
                }
            }
        }
        catch(Throwable th) {
            throw new FacesException(th);
        }
        finally
        {
            try
            {
                if(addResource!=null)
                {
                    addResource.responseFinished();
                }
            }
            finally
            {
                delegate.release();
View Full Code Here

Examples of org.apache.myfaces.renderkit.html.util.AddResource

                //release() method write to the original response.
                //This could not be done on TomahawkFacesContextWrapper
                //constructor, because the delegate ExternalContext do
                //calls like dispatch, forward and redirect, that requires
                //the wrapped response instance to work properly.           
                AddResource addResource = AddResourceFactory.getInstance((HttpServletRequest)request,(ServletContext)context);
               
                if (addResource.requiresBuffer())
                {
                    ExtensionsResponseWrapper extensionsResponseWrapper = new ExtensionsResponseWrapper((HttpServletResponse)response);
                    return new TomahawkFacesContextWrapper(delegate.getFacesContext(context, request, extensionsResponseWrapper, lifecycle),
                            extensionsResponseWrapper);
                }
View Full Code Here

Examples of org.apache.myfaces.renderkit.html.util.AddResource

        /* check whether we have a debugging flag already set */
        if (isInlineScriptSet(facesContext, "/*DOJO DEBUGCONSOLE ON*/"))
            return;

        AddResource addResource = AddResourceFactory.getInstance(facesContext);
        addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, "/*DOJO DEBUGCONSOLE ON*/");

        ResponseWriter writer = facesContext.getResponseWriter();
        // we for now have to break html until the dynamic creation
        // isses are resolved, so hold on for this messy code now
        // Since this is for debugging purposes only, we can live with it
View Full Code Here

Examples of org.apache.myfaces.renderkit.html.util.AddResource

        return isInlineScriptCheck(facesContext, DJCONFIG_INITKEY);
    }

    public static void addMainInclude(FacesContext facesContext, UIComponent component, String javascriptLocation, DojoConfig config) throws IOException {

        AddResource addResource = AddResourceFactory.getInstance(facesContext);

        /*
         * var djConfig = { isDebug: false }; TODO add a saner handling of
         * collecting all djconfig data and then merging it
         */
        if (!isInlineScriptSet(facesContext, DJCONFIG_INITKEY)) {
            addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, DJCONFIG_INITKEY);
            addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, config.toString());

            String dojofile = ((getExpanded(facesContext) != null) && getExpanded(facesContext).booleanValue()) ? DOJO_FILE_UNCOMPRESSED : DOJO_FILE;

            if (javascriptLocation != null) {
                addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, javascriptLocation + dojofile);
            } else {
                /*
                 * ResponseWriter writer = facesContext.getResponseWriter();
                 * writer.startElement(HTML.SCRIPT_ELEM,component);
                 *
                 * MyFacesResourceHandler handler = new
                 * MyFacesResourceHandler(DojoResourceLoader.class, dojofile);
                 * String uri = handler.getResourceUri(facesContext); uri =
                 * uri.replaceAll("dojo\\.js\\;jsessionid(.)*\\\"","dojo.js");
                 * writer.writeAttribute(HTML.SRC_ATTR, uri, null);
                 *
                 * writer.endElement(HTML.SCRIPT_ELEM);
                 * addResource.addJavaScriptAtPosition(facesContext,
                 * AddResource.HEADER_BEGIN, DojoResourceLoader.class,
                 * dojofile);
                 */

                addResource.addJavaScriptAtPositionPlain(facesContext, AddResource.HEADER_BEGIN, DojoResourceLoader.class, dojofile);
            }
            addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, DOJOEXTENSIONS_NAMESPACE);
        }
    }
View Full Code Here

Examples of org.apache.myfaces.renderkit.html.util.AddResource

    public static void addProvide(FacesContext context, String provided) {

        if (isInlineScriptSet(context, DOJO_PROVIDE + provided))
            return;

        AddResource addResource = AddResourceFactory.getInstance(context);
        String providedBuilder = createDojoProvideScript(provided);

        addResource.addInlineScriptAtPosition(context, AddResource.HEADER_BEGIN, providedBuilder);
    }
View Full Code Here

Examples of org.apache.myfaces.renderkit.html.util.AddResource

        if (facesContext.getExternalContext().getRequestMap().containsKey(JAVASCRIPT_ENCODED))
        {
            return;
        }

        AddResource addresource = AddResourceFactory.getInstance(facesContext);
        // Add the javascript and CSS pages

        String styleLocation = HtmlRendererUtils.getStyleLocation(component);

        if(styleLocation==null)
        {
            addresource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "WH/theme.css");
            addresource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "DB/theme.css");
        }
        else if (!RESOURCE_NONE.equals(styleLocation))
        {
            addresource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, styleLocation+"/theme.css");
        }
        else
        {
            // output nothing; presumably the page directly references the necessary stylesheet
        }

        String javascriptLocation = HtmlRendererUtils.getJavascriptLocation(component);

        if(javascriptLocation==null)
        {
            addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, PrototypeResourceLoader.class, "prototype.js");
            addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "date.js");
            addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "popcalendar.js");
        }
        else if (!RESOURCE_NONE.equals(javascriptLocation))
        {
            addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, javascriptLocation+ "/prototype.js");
            addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, javascriptLocation+ "/date.js");
            addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, javascriptLocation+ "/popcalendar.js");
        }
        else
        {
            // output nothing; presumably the page directly references the necessary javascript
        }
View Full Code Here

Examples of org.apache.myfaces.renderkit.html.util.AddResource

        {
            throw new IllegalStateException("Week may only start with saturday, sunday or monday.");
        }

        StringBuffer script = new StringBuffer();
        AddResource ar = AddResourceFactory.getInstance(facesContext);

        if (uiComponent instanceof HtmlInputCalendar)
        {
            HtmlInputCalendar calendar = (HtmlInputCalendar) uiComponent;
            // Set the themePrefix variable
            String popupTheme = calendar.getPopupTheme();
            if (popupTheme == null)
            {
                popupTheme = "DB";
            }
            setStringVariable(script, popupCalendarVariable + ".initData.themePrefix",
                    "jscalendar-" + popupTheme);

            // specify the URL for the directory in which all the .gif images
            // can be found
            String imageLocation = HtmlRendererUtils.getImageLocation(uiComponent);
            if (imageLocation == null)
            {
                String uri = ar.getResourceUri(facesContext, HtmlCalendarRenderer.class, popupTheme
                        + "/");
                setStringVariable(script, popupCalendarVariable + ".initData.imgDir",
                        JavascriptUtils.encodeString(uri));
            }
            else
            {
                setStringVariable(script, popupCalendarVariable + ".initData.imgDir",
                        (JavascriptUtils.encodeString(AddResourceFactory.getInstance(facesContext)
                                .getResourceUri(facesContext, imageLocation + "/"))));
            }
        }
        else
        {
            String imageLocation = HtmlRendererUtils.getImageLocation(uiComponent);
            if (imageLocation == null)
            {
                String uri = ar.getResourceUri(facesContext, HtmlCalendarRenderer.class, "images/");
                setStringVariable(script, popupCalendarVariable + ".initData.imgDir",
                        JavascriptUtils.encodeString(uri));
            }
            else
            {
View Full Code Here

Examples of org.apache.myfaces.renderkit.html.util.AddResource

            writer.endElement(HTML.INPUT_ELEM);
        } else {
            // render the image
            writer.startElement(HTML.IMG_ELEM, uiComponent);
            AddResource addResource = AddResourceFactory.getInstance(facesContext);

            String imgUrl = (String) uiComponent.getAttributes().get("popupButtonImageUrl");

            if(imgUrl!=null)
            {
                writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, imgUrl), null);
            }
            else
            {
                writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, HtmlCalendarRenderer.class, "images/calendar.gif"), null);
            }

            if(popupButtonStyle != null)
            {
                writer.writeAttribute(HTML.STYLE_ATTR, popupButtonStyle, null);
View Full Code Here

Examples of org.apache.myfaces.renderkit.html.util.AddResource

    private void addResourcesToHeader(String themeName, HtmlCommandJSCookMenu menu, FacesContext context) {
        String javascriptLocation = (String) menu.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
        String imageLocation = (String) menu.getAttributes().get(JSFAttr.IMAGE_LOCATION);
        String styleLocation = (String) menu.getAttributes().get(JSFAttr.STYLE_LOCATION);

        AddResource addResource = AddResourceFactory.getInstance(context);

        if (javascriptLocation != null) {
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/" + JSCOOK_MENU_SCRIPT);
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/" + JSCOOK_EFFECT_SCRIPT);           
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/" + MYFACES_HACK_SCRIPT);
        }
        else {
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, JSCOOK_MENU_SCRIPT);
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, JSCOOK_EFFECT_SCRIPT);           
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, MYFACES_HACK_SCRIPT);
        }

        addThemeSpecificResources(themeName, styleLocation, javascriptLocation, imageLocation, context);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.