Package org.apache.myfaces.renderkit.html.util

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


    protected void writeBeforeEnd(FacesContext facesContext) throws IOException
    {
        super.writeBeforeEnd(facesContext);
       
        AddResource addResource = AddResourceFactory.getInstance(facesContext);
        if (addResource instanceof StreamingAddResource)
        {
            ((StreamingAddResource) addResource).addStyleLoaderHere(facesContext, DocumentHead.class);
        }
    }
View Full Code Here


        HtmlSchedule schedule = (HtmlSchedule) component;
        ResponseWriter writer = context.getResponseWriter();

        //add needed CSS and Javascript files to the header

        AddResource addResource = AddResourceFactory.getInstance(context);
        String theme = schedule.getTheme();
        //The default css file is only loaded if the theme is one of the provided
        //themes.
        if (DEFAULT_THEME.equals(theme) || OUTLOOK_THEME.equals(theme)
                || EVOLUTION_THEME.equals(theme))
        {
            addResource.addStyleSheet(context, AddResource.HEADER_BEGIN,
                    HtmlSchedule.class, CSS_RESOURCE);
        }
        addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN,
                HtmlSchedule.class, "javascript/schedule.js");
       
        if (schedule.isTooltip())
        {
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN,
                    HtmlSchedule.class, "javascript/alphaAPI.js");
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN,
                    HtmlSchedule.class, "javascript/domLib.js");
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN,
                    HtmlSchedule.class, "javascript/domTT.js");
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN,
                    HtmlSchedule.class, "javascript/fadomatic.js");
        }
       
        //hidden input field containing the id of the selected entry
        writer.startElement(HTML.INPUT_ELEM, schedule);
View Full Code Here

        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

        {
            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

           
            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

        /* 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

        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

    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

    private void encodeJavascript(FacesContext facesContext,
                                  UIComponent uiComponent)
    {
        // AddResource takes care to add only one reference to the same script
        AddResource addResource = AddResourceFactory.getInstance(facesContext);
        addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN,
                                            HtmlPicklistRenderer.class, "picklist.js");
    }
View Full Code Here

     */
    private void generateImageTag(FacesContext context,
            CAPTCHAComponent component) throws IOException
    {

        AddResource addResource;
        ResponseWriter writer = context.getResponseWriter();
        Map params = HtmlComponentUtils.getParameterMap(component);
        String url;
        String captchaSessionKeyName = component.getCaptchaSessionKeyName();
        String width = component.getImageWidth();
        String height = component.getImageHeight();

        // determine width and height of the generated image.
        if (width == null)
        {
            width = CAPTCHAConstants.DEFAULT_CAPTCHA_WIDTH + "";
        }

        if (height == null)
        {
            height = CAPTCHAConstants.DEFAULT_CAPTCHA_HEIGHT + "";
        }

        writer.startElement(HTML.IMG_ELEM, component);

        // constructing the parameter map to be passed to the (AddResource).
        if (captchaSessionKeyName != null)
        {
            params.put(CAPTCHAComponent.ATTRIBUTE_CAPTCHA_SESSION_KEY_NAME,
                    captchaSessionKeyName);
        }

        // write the url to trigger the (AddResource).
        addResource = AddResourceFactory.getInstance(context);

        url = context.getExternalContext().encodeResourceURL(
                addResource.getResourceUri(context,
                        new ParameterResourceHandler(this.getClass(), params)));

        // adding dummy parameter to prevent caching.
        writer.writeAttribute(HTML.SRC_ATTR, url + "&dummyParameter="
                + System.currentTimeMillis(), null);
View Full Code Here

TOP

Related Classes of org.apache.myfaces.renderkit.html.util.AddResource

Copyright © 2018 www.massapicom. 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.