Examples of AddResource


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

        renderWidgetInitializationCode(writer, component, DEBUG_CONSOLE_TYPE, attributeMap, MYFACES_DOJO_DEBUGCONSOLE_ID, true);
    }

    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

     */
    private void encodeJavascript(FacesContext context, UIComponent component) throws IOException
    {
        // render javascript function for client-side toggle (it won't be used if user has opted for server-side toggle)
        String javascriptLocation = ((HtmlTree)component).getJavascriptLocation();
        AddResource addResource = AddResourceFactory.getInstance(context);
        if (javascriptLocation == null)
        {
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlTreeRenderer.class, "javascript/tree.js");
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlTreeRenderer.class, "javascript/cookielib.js");
        }
        else
        {
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/tree.js");
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/cookielib.js");
        }
    }
View Full Code Here

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

     * @return The image src information.
     */
    private String getImageSrc(FacesContext context, UIComponent component, String imageName, boolean withContextPath)
    {
        String imageLocation = ((HtmlTree)component).getImageLocation();
        AddResource addResource = AddResourceFactory.getInstance(context);
        if (imageLocation == null)
        {
            return addResource.getResourceUri(context, HtmlTreeRenderer.class,
                                              "images/" + imageName, withContextPath);
        }
        else
        {
            return addResource.getResourceUri(context, imageLocation + "/" + imageName, withContextPath);
        }
    }
View Full Code Here

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

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

        //add needed CSS and Javascript files to the header

        AddResource addResource = AddResourceFactory.getInstance(context);
        String theme = getTheme(schedule);
        //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");
        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);
        writer.writeAttribute(HTML.TYPE_ATTR, "hidden", null);
View Full Code Here

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

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

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

            if (log.isWarnEnabled()) log.warn("PanelNavaigationMenu without children.");
        }
    }

    private void addResourcesToHeader(FacesContext context) {
        AddResource addResource = AddResourceFactory.getInstance(context);
        addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlPanelNavigationMenu.class, HORIZ_MENU_SCRIPT);
    }
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 + "/" + MYFACES_HACK_SCRIPT);
        }
        else {
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, JSCOOK_MENU_SCRIPT);
            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, MYFACES_HACK_SCRIPT);
        }

        addThemeSpecificResources(themeName, styleLocation, javascriptLocation, imageLocation, context);
    }
View Full Code Here

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

        String themeLocation = (String) builtInThemes.get(themeName);
        if (themeLocation == null) {
            log.debug("Unknown theme name '" + themeName + "' specified.");
        }

        AddResource addResource = AddResourceFactory.getInstance(context);

        if ((imageLocation != null) || (themeLocation != null)) {
            // Generate a javascript variable containing a reference to the
            // directory containing theme image files, for use by the theme
            // javascript file. If neither of these is defined (ie a custom
            // theme was specified but no imageLocation) then presumably the
            // theme.js file uses some other mechanism to determine where
            // its image files are.
            StringBuffer buf = new StringBuffer();
            buf.append("var my");
            buf.append(themeName);
            buf.append("Base='");
            ExternalContext externalContext = context.getExternalContext();
            if (imageLocation != null) {
                buf.append(externalContext.encodeResourceURL(addResource.getResourceUri(context,
                                                                                        imageLocation + "/" + themeName)));
            }
            else {
                buf.append(externalContext.encodeResourceURL(addResource.getResourceUri(context,
                                                                                        HtmlJSCookMenuRenderer.class, themeLocation)));
            }
            buf.append("';");
            addResource.addInlineScriptAtPosition(context, AddResource.HEADER_BEGIN, buf.toString());
        }


        if ((javascriptLocation != null) || (themeLocation != null)) {
            // Generate a <script> tag in the page header pointing to the
            // theme.js file for this theme. If neither of these is defined
            // then presumably the theme.js file is referenced by a <script>
            // tag hard-wired into the page or inserted via some other means.
            if (javascriptLocation != null) {
                // For now, assume that if the user specified a location for a custom
                // version of the jscookMenu.js file then the theme.js file can be found
                // in the same location.
                addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/" + themeName
                    + "/theme.js");
            }
            else {
                // Using a built-in theme, so we know where the theme.js file is.
                addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, themeName
                    + "/theme.js");
            }
        }

        if ((styleLocation != null) || (themeLocation != null)) {
            // Generate a <link type="text/css"> tag in the page header pointing to
            // the theme stylesheet. If neither of these is defined then presumably
            // the stylesheet is referenced by a <link> tag hard-wired into the page
            // or inserted via some other means.
            if (styleLocation != null) {
                addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, styleLocation + "/" + themeName + "/theme.css");
            }
            else {
                addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, themeName
                    + "/theme.css");
            }
        }
    }
View Full Code Here

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
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.