You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/04/29 00:47:02 UTC

svn commit: r939124 - in /myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces: component/ custom/calendar/ custom/navmenu/jscookmenu/ custom/tree/renderkit/html/ custom/tree2/ tomahawk/util/

Author: lu4242
Date: Wed Apr 28 22:47:01 2010
New Revision: 939124

URL: http://svn.apache.org/viewvc?rev=939124&view=rev
Log:
TOMAHAWK-1472 Add Support for new Resource API in tomahawk 2.0 module

Added:
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/LibraryLocationAware.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/AbstractHtmlInputCalendar.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/AbstractHtmlCommandJSCookMenu.java
Modified:
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeImageCommandLinkRenderer.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/AbstractHtmlTree.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/tomahawk/util/TomahawkResourceUtils.java

Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/LibraryLocationAware.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/LibraryLocationAware.java?rev=939124&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/LibraryLocationAware.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/LibraryLocationAware.java Wed Apr 28 22:47:01 2010
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.component;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
+
+/**
+ * 
+ * @since 1.1.10
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 691856 $ $Date: 2008-09-03 21:40:30 -0500 (mié, 03 sep 2008) $
+ */
+public interface LibraryLocationAware
+{
+    public static final String STYLE_LIBRARY_ATTR = "styleLibrary";
+    public static final String JAVASCRIPT_LIBRARY_ATTR = "javascriptLibrary";
+    public static final String IMAGE_LIBRARY_ATTR = "imageLibrary";
+    
+    /**
+     *  
+     */
+    @JSFProperty
+    public String getJavascriptLibrary();
+    
+    /**
+     *  
+     */
+    @JSFProperty
+    public String getImageLibrary();
+    
+    /**
+     * 
+     */
+    @JSFProperty
+    public String getStyleLibrary();
+
+}

Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/AbstractHtmlInputCalendar.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/AbstractHtmlInputCalendar.java?rev=939124&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/AbstractHtmlInputCalendar.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/AbstractHtmlInputCalendar.java Wed Apr 28 22:47:01 2010
@@ -0,0 +1,299 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.calendar;
+
+import org.apache.myfaces.component.AlignProperty;
+import org.apache.myfaces.component.LibraryLocationAware;
+import org.apache.myfaces.component.LocationAware;
+import org.apache.myfaces.component.UserRoleAware;
+import org.apache.myfaces.component.UserRoleUtils;
+import org.apache.myfaces.component.html.ext.HtmlInputText;
+
+/**
+ *  <p>
+ *  Provides a calendar. The calendar can be "inline", or a button can be rendered
+ *  that displays the calendar in a "popup window" when clicked. Javascript is
+ *  required for the popup window.
+ *  </p>
+ *  <p>
+ *  The two forms of calendar are unfortunately not well integrated; this component is
+ *  effectively two components that happen to use the same component class. Some
+ *  attributes on the component are applicable only to the inline form while others
+ *  are applicable only to the popup form.
+ *  </p>
+ *  <p>
+ *  The appearance of the inline calendar can be controlled via attributes
+ *  such as currentDayCellClass, dayCellClass, weekRowClass, monthYearRowClass. 
+ *  Attributes "styleLocation", "javascriptLocation", "imageLocation" and all
+ *  attributes starting with "popup" have no effect on an inline calendar.
+ *  </p>
+ *  <ul>
+ *  <p>
+ *  The appearance of the popup calendar can be controlled via attributes
+ *  popupTheme, styleLocation, javascriptLocation and imageLocation:
+ *  </p>
+ *    <li>popupTheme: When styleLocation is not overridden then this selects one of the
+ *    built-in themes ("WH" or "DB"); the default is "DB". This also selects the prefix
+ * used for the names of style classes attached to generated dom elements; all style
+ * names are of form "jscalendar-{popupTheme}-*".  
+ * </li>
+ * <li>styleLocation: specifies the URL of a directory in which a "theme.css" file exists.
+ *  A reference to this theme.css file will automatically be output. Specifying "none" as the
+ *  location prevents the generation of this stylesheet reference; it is assumed that the
+ *  necessary style rules will be loaded via some other mechanism. Defaults to a reference
+ *  to a location within the tomahawk jarfile which varies based on popupTheme.</li>
+ * <li>javascriptLocation: specifies the URL of a directory in which all the necessary script
+ *   files can be found. A reference to scripts "prototype.js", "date.js" and "popcalendar.js"
+ *   will automatically be output. Specifying "none" prevents generation of these references;
+ *       it is assumed that the necessary javascript functions will be loaded via some other
+ *       mechanism. Defaults to a reference to a location within the tomahawk jarfile.</li>
+ *    <li>imageLocation: specifies the URL of a directory in which all the necessary icons are
+ *       defined. Defaults to a reference to a location within the tomahawk jarfile which
+ *       varies depending on popupTheme.</li>
+ *  </ul>
+ *  Other styling attributes (eg dayCellClass, weekRowClass) are ignored for the popup calendar.
+ *  <p>
+ *  Unless otherwise specified, all attributes accept static values or EL expressions.
+ *  </p>
+ * 
+ * @JSFComponent
+ *   name = "t:inputCalendar"
+ *   class = "org.apache.myfaces.custom.calendar.HtmlInputCalendar"
+ *   tagClass = "org.apache.myfaces.custom.calendar.HtmlInputCalendarTag"
+ * @since 1.1.7
+ * @author Martin Marinschek (latest modification by $Author: lu4242 $)
+ * @version $Revision: 691856 $ $Date: 2008-09-03 21:40:30 -0500 (mié, 03 sep 2008) $
+ */
+public abstract class AbstractHtmlInputCalendar
+        extends HtmlInputText implements UserRoleAware, LocationAware,
+        AlignProperty, LibraryLocationAware
+{
+
+    public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlInputCalendar";
+    private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Calendar";
+    
+    public boolean isRendered()
+    {
+        if (!UserRoleUtils.isVisibleOnUserRole(this)) return false;
+        return super.isRendered();
+    }
+        
+    /**
+     * CSS class to be used on the TR element for the header-row showing month and year.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getMonthYearRowClass();
+
+    /**
+     * CSS class to be used on the TR element for the header-row showing the week-days.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getWeekRowClass();
+
+    /**
+     * CSS class to be used for the TD element containing a day days.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getDayCellClass();
+
+    /**
+     * CSS class to be used for the TD element of the currently selected date.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getCurrentDayCellClass();
+
+    /**
+     * Render the input-calendar left of the button, not right like normally done.
+     * 
+     * @JSFProperty
+     *   defaultValue = "false" 
+     */
+    public abstract boolean isPopupLeft();
+
+    /**
+     * Render the input-calendar as a java-script popup on client.
+     * 
+     * @JSFProperty
+     *   defaultValue = false; 
+     */
+    public abstract boolean isRenderAsPopup();
+
+    /**
+     * Automatically add the input-calendar scripts and css files to 
+     * the header - set that to false to provide the scripts yourself.
+     * 
+     * @JSFProperty
+     *   defaultValue = "true" 
+     */
+    public abstract boolean isAddResources();
+    
+    public abstract void setAddResources(boolean value);
+    
+    public void setAddResources(Boolean value)
+    {
+        this.setAddResources(value.booleanValue());
+    }
+
+    /**
+     * Defines the string displayed on the button which leads to 
+     * the calendar-popup-window (... by default).
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupButtonString();
+
+    /**
+     * Defines the css style for the button which leads to the 
+     * calendar-popup-window.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupButtonStyle();
+
+    /**
+     * Defines the css style class for the button which leads to the 
+     * calendar-popup-window.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupButtonStyleClass();
+
+    /**
+     * If true, renders a calendar icon instead of the button to pop up the calendar.
+     * 
+     * @JSFProperty
+     *   defaultValue = "false" 
+     */
+    public abstract boolean isRenderPopupButtonAsImage();
+
+    /**
+     * Defines the date format used by the java-script popup on client.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupDateFormat();
+    
+    /**
+     * Set the string for "Go To Current Month"
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupGotoString();
+
+    /**
+     * Set the string for "Today is"
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupTodayString();
+
+    /**
+     * Defines the date format used by the java-script popup 
+     * on client for the today-is string.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupTodayDateFormat();
+
+    /**
+     * Set the string for "Wk"
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupWeekString();
+
+    /**
+     * Set the string for scrolling to the left.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupScrollLeftMessage();
+
+    /**
+     * Set the string for scrolling to the right.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupScrollRightMessage();
+
+    /**
+     * Set the string for "Click to select a month".
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupSelectMonthMessage();
+
+    /**
+     * Set the string for "Click to select a year".
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupSelectYearMessage();
+
+    /**
+     * Set the string for "Select [date] as date" (do not 
+     * replace [date], it will be replaced by the current date).
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupSelectDateMessage();
+
+    /**
+     * Set the theme-prefix for this component.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupTheme();
+
+    /**
+     * Url to the image for this popupButton.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getPopupButtonImageUrl();
+
+    /**
+     * The text that will be rendered in the field - helping the 
+     * user to find the right format to enter into the field.
+     * 
+     * @JSFProperty 
+     */
+    public abstract String getHelpText();
+
+
+    /**
+     * <p>
+     * May be "day", "week", "month" or "none":
+     * <ul>
+     * <li>day (default): allow the user to select a day.</li>
+     * <li>week: only allow the user to select a week.</li>
+     * <li>month: only allow the user to select a month.</li> 
+     * <li>none: equivalent to "readonly".</li> 
+     * </ul>
+     * </p>
+     * 
+     * @JSFProperty
+     *   defaultValue = "day" 
+     */
+    public abstract String getPopupSelectMode();
+}
\ No newline at end of file

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java?rev=939124&r1=939123&r2=939124&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java Wed Apr 28 22:47:01 2010
@@ -51,6 +51,7 @@ import javax.faces.event.ListenerFor;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.component.LibraryLocationAware;
 import org.apache.myfaces.component.UserRoleUtils;
 import org.apache.myfaces.custom.inputTextHelp.HtmlInputTextHelp;
 import org.apache.myfaces.dateformat.SimpleDateFormatter;
@@ -430,10 +431,18 @@ public class HtmlCalendarRenderer
 
         if(styleLocation==null)
         {
-            //addresource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "WH/theme.css");
-            TomahawkResourceUtils.addOutputStylesheetResource(facesContext, "oam.custom.calendar.WH", "theme.css");
-            //addresource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "DB/theme.css");
-            TomahawkResourceUtils.addOutputStylesheetResource(facesContext, "oam.custom.calendar.DB", "theme.css");
+            String styleLibrary = (String) component.getAttributes().get(LibraryLocationAware.STYLE_LIBRARY_ATTR);
+            if (styleLibrary == null)
+            {
+                //addresource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "WH/theme.css");
+                TomahawkResourceUtils.addOutputStylesheetResource(facesContext, "oam.custom.calendar.WH", "theme.css");
+                //addresource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "DB/theme.css");
+                TomahawkResourceUtils.addOutputStylesheetResource(facesContext, "oam.custom.calendar.DB", "theme.css");
+            }
+            else
+            {
+                TomahawkResourceUtils.addOutputStylesheetResource(facesContext, styleLocation, "theme.css");
+            }
         }
         else if (!RESOURCE_NONE.equals(styleLocation))
         {
@@ -448,12 +457,23 @@ public class HtmlCalendarRenderer
 
         if(javascriptLocation==null)
         {
-            //addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, PrototypeResourceLoader.class, "prototype.js");
-            TomahawkResourceUtils.addOutputScriptResource(facesContext, "oam.custom.prototype", "prototype.js");
-            //addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "date.js");
-            TomahawkResourceUtils.addOutputScriptResource(facesContext, "oam.custom.calendar", "date.js");
-            //addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "popcalendar.js");
-            TomahawkResourceUtils.addOutputScriptResource(facesContext, "oam.custom.calendar", "popcalendar.js");
+            String javascriptLibrary = (String) component.getAttributes().get(LibraryLocationAware.JAVASCRIPT_LIBRARY_ATTR);
+            if (javascriptLibrary == null)
+            {
+                //addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, PrototypeResourceLoader.class, "prototype.js");
+                TomahawkResourceUtils.addOutputScriptResource(facesContext, "oam.custom.prototype", "prototype.js");
+                //addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "date.js");
+                TomahawkResourceUtils.addOutputScriptResource(facesContext, "oam.custom.calendar", "date.js");
+                //addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "popcalendar.js");
+                TomahawkResourceUtils.addOutputScriptResource(facesContext, "oam.custom.calendar", "popcalendar.js");
+            }
+            else
+            {
+                TomahawkResourceUtils.addOutputScriptResource(facesContext, javascriptLibrary, "prototype.js");
+                TomahawkResourceUtils.addOutputScriptResource(facesContext, javascriptLibrary, "date.js");
+                TomahawkResourceUtils.addOutputScriptResource(facesContext, javascriptLibrary, "popcalendar.js");
+
+            }
         }
         else if (!RESOURCE_NONE.equals(javascriptLocation))
         {
@@ -531,18 +551,33 @@ public class HtmlCalendarRenderer
             String imageLocation = HtmlRendererUtils.getImageLocation(uiComponent);
             if (imageLocation == null)
             {
-                //String uri = ar.getResourceUri(facesContext, HtmlCalendarRenderer.class, popupTheme
-                //        + "/");
-                //setStringVariable(script, popupCalendarVariable + ".initData.imgDir",
-                //        JavascriptUtils.encodeString(uri));
-                Resource resource = facesContext.getApplication().getResourceHandler().createResource(
-                        ";j", "oam.custom.calendar"+((popupTheme!=null&&popupTheme.length()>0)?"."+popupTheme:""));
-                String path = resource.getRequestPath();
-                int index = path.indexOf("/;j");
-                String prefix = path.substring(0, index+1); 
-                String suffix = path.substring(index+3);
-                setStringVariable(script, popupCalendarVariable + ".initData.imgDir",prefix);
-                setStringVariable(script, popupCalendarVariable + ".initData.imgDirSuffix",suffix);
+                String imageLibrary = (String) uiComponent.getAttributes().get(LibraryLocationAware.IMAGE_LIBRARY_ATTR);
+                if (imageLibrary == null)
+                {
+                    //String uri = ar.getResourceUri(facesContext, HtmlCalendarRenderer.class, popupTheme
+                    //        + "/");
+                    //setStringVariable(script, popupCalendarVariable + ".initData.imgDir",
+                    //        JavascriptUtils.encodeString(uri));
+                    Resource resource = facesContext.getApplication().getResourceHandler().createResource(
+                            ";j", "oam.custom.calendar"+((popupTheme!=null&&popupTheme.length()>0)?"."+popupTheme:""));
+                    String path = resource.getRequestPath();
+                    int index = path.indexOf("/;j");
+                    String prefix = path.substring(0, index+1); 
+                    String suffix = path.substring(index+3);
+                    setStringVariable(script, popupCalendarVariable + ".initData.imgDir",prefix);
+                    setStringVariable(script, popupCalendarVariable + ".initData.imgDirSuffix",suffix);
+                }
+                else
+                {
+                    Resource resource = facesContext.getApplication().getResourceHandler().createResource(
+                            ";j", imageLibrary);
+                    String path = resource.getRequestPath();
+                    int index = path.indexOf("/;j");
+                    String prefix = path.substring(0, index+1); 
+                    String suffix = path.substring(index+3);
+                    setStringVariable(script, popupCalendarVariable + ".initData.imgDir",prefix);
+                    setStringVariable(script, popupCalendarVariable + ".initData.imgDirSuffix",suffix);                    
+                }
             }
             else
             {
@@ -557,18 +592,33 @@ public class HtmlCalendarRenderer
             String imageLocation = HtmlRendererUtils.getImageLocation(uiComponent);
             if (imageLocation == null)
             {
-                //String uri = ar.getResourceUri(facesContext, HtmlCalendarRenderer.class, "images/");
-                //setStringVariable(script, popupCalendarVariable + ".initData.imgDir",
-                ///        JavascriptUtils.encodeString(uri));
-                //setStringVariable(script, popupCalendarVariable + ".initData.imgDirSuffix","");
-                Resource resource = facesContext.getApplication().getResourceHandler().createResource(
-                        ";j", "oam.custom.calendar.images");
-                String path = resource.getRequestPath();
-                int index = path.indexOf("/;j");
-                String prefix = path.substring(0, index+1); 
-                String suffix = path.substring(index+3);
-                setStringVariable(script, popupCalendarVariable + ".initData.imgDir",prefix);
-                setStringVariable(script, popupCalendarVariable + ".initData.imgDirSuffix",suffix);
+                String imageLibrary = (String) uiComponent.getAttributes().get(LibraryLocationAware.IMAGE_LIBRARY_ATTR);
+                if (imageLibrary == null)
+                {
+                    //String uri = ar.getResourceUri(facesContext, HtmlCalendarRenderer.class, "images/");
+                    //setStringVariable(script, popupCalendarVariable + ".initData.imgDir",
+                    ///        JavascriptUtils.encodeString(uri));
+                    //setStringVariable(script, popupCalendarVariable + ".initData.imgDirSuffix","");
+                    Resource resource = facesContext.getApplication().getResourceHandler().createResource(
+                            ";j", "oam.custom.calendar.images");
+                    String path = resource.getRequestPath();
+                    int index = path.indexOf("/;j");
+                    String prefix = path.substring(0, index+1); 
+                    String suffix = path.substring(index+3);
+                    setStringVariable(script, popupCalendarVariable + ".initData.imgDir",prefix);
+                    setStringVariable(script, popupCalendarVariable + ".initData.imgDirSuffix",suffix);
+                }
+                else
+                {
+                    Resource resource = facesContext.getApplication().getResourceHandler().createResource(
+                            ";j", imageLibrary);
+                    String path = resource.getRequestPath();
+                    int index = path.indexOf("/;j");
+                    String prefix = path.substring(0, index+1); 
+                    String suffix = path.substring(index+3);
+                    setStringVariable(script, popupCalendarVariable + ".initData.imgDir",prefix);
+                    setStringVariable(script, popupCalendarVariable + ".initData.imgDirSuffix",suffix);
+                }
             }
             else
             {

Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/AbstractHtmlCommandJSCookMenu.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/AbstractHtmlCommandJSCookMenu.java?rev=939124&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/AbstractHtmlCommandJSCookMenu.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/AbstractHtmlCommandJSCookMenu.java Wed Apr 28 22:47:01 2010
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.navmenu.jscookmenu;
+
+import javax.faces.component.UICommand;
+
+import org.apache.myfaces.component.LibraryLocationAware;
+import org.apache.myfaces.component.LocationAware;
+import org.apache.myfaces.component.UserRoleAware;
+import org.apache.myfaces.component.UserRoleUtils;
+
+/**
+ * Renders a Javascript Menu. Nested NavigationMenuItem(s) are rendered 
+ * as Javascript Menu. 
+ *
+ * <p>
+ * This component is based based on the excellent
+ * <a href="http://jscook.sourceforge.net/JSCookMenu">JSCookMenu</a>
+ * by Heng Yuan.
+ * </p>
+ * 
+ * Unless otherwise specified, all attributes accept static values or EL expressions.
+ * 
+ * @JSFComponent
+ *   name = "t:jscookMenu"
+ *   class = "org.apache.myfaces.custom.navmenu.jscookmenu.HtmlCommandJSCookMenu"
+ *   tagClass = "org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuTag"
+ * 
+ * @JSFJspProperty name = "value" tagExcluded = "true"
+ * @JSFJspProperty name = "actionListener" tagExcluded = "true"
+ * @JSFJspProperty name = "action" tagExcluded = "true"
+ * @since 1.1.7
+ * @author Thomas Spiegl (latest modification by $Author: lu4242 $)
+ * @version $Revision: 691856 $ $Date: 2008-09-03 21:40:30 -0500 (mié, 03 sep 2008) $
+ */
+public abstract class AbstractHtmlCommandJSCookMenu
+    extends UICommand
+    implements UserRoleAware, LocationAware, LibraryLocationAware
+{
+    //private static final Log log = LogFactory.getLog(HtmlCommandJSCookMenu.class);
+
+    public static final String COMPONENT_TYPE = "org.apache.myfaces.JSCookMenu";
+    public static final String COMPONENT_FAMILY = "javax.faces.Command";
+    private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.JSCookMenu";
+    
+    /**
+     * @JSFProperty
+     *   required = "true"
+     */
+    public abstract String getLayout();
+
+    /**
+     * @JSFProperty
+     *   required = "true"
+     */
+    public abstract String getTheme();
+
+    public boolean isRendered()
+    {
+        if (!UserRoleUtils.isVisibleOnUserRole(this)) return false;
+        return super.isRendered();
+    }
+
+}

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java?rev=939124&r1=939123&r2=939124&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java Wed Apr 28 22:47:01 2010
@@ -40,6 +40,7 @@ import javax.faces.event.ListenerFor;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.component.LibraryLocationAware;
 import org.apache.myfaces.custom.navmenu.NavigationMenuItem;
 import org.apache.myfaces.custom.navmenu.NavigationMenuUtils;
 import org.apache.myfaces.custom.navmenu.UINavigationMenuItem;
@@ -429,6 +430,9 @@ public class HtmlJSCookMenuRenderer
         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);
+        String javascriptLibrary = (String) menu.getAttributes().get(LibraryLocationAware.JAVASCRIPT_LIBRARY_ATTR);
+        String imageLibrary = (String) menu.getAttributes().get(LibraryLocationAware.IMAGE_LIBRARY_ATTR);
+        String styleLibrary = (String) menu.getAttributes().get(LibraryLocationAware.STYLE_LIBRARY_ATTR);
 
         AddResource addResource = AddResourceFactory.getInstance(context);
 
@@ -438,15 +442,25 @@ public class HtmlJSCookMenuRenderer
             addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/" + MYFACES_HACK_SCRIPT);
         }
         else {
-            //addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, JSCOOK_MENU_SCRIPT);
-            TomahawkResourceUtils.addOutputScriptResource(context, "oam.custom.navmenu.jscookmenu", JSCOOK_MENU_SCRIPT);
-            //addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, JSCOOK_EFFECT_SCRIPT);
-            TomahawkResourceUtils.addOutputScriptResource(context, "oam.custom.navmenu.jscookmenu", JSCOOK_EFFECT_SCRIPT);
-            //addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, MYFACES_HACK_SCRIPT);
-            TomahawkResourceUtils.addOutputScriptResource(context, "oam.custom.navmenu.jscookmenu", MYFACES_HACK_SCRIPT);
+            if (javascriptLibrary == null)
+            {
+                //addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, JSCOOK_MENU_SCRIPT);
+                TomahawkResourceUtils.addOutputScriptResource(context, "oam.custom.navmenu.jscookmenu", JSCOOK_MENU_SCRIPT);
+                //addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, JSCOOK_EFFECT_SCRIPT);
+                TomahawkResourceUtils.addOutputScriptResource(context, "oam.custom.navmenu.jscookmenu", JSCOOK_EFFECT_SCRIPT);
+                //addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlJSCookMenuRenderer.class, MYFACES_HACK_SCRIPT);
+                TomahawkResourceUtils.addOutputScriptResource(context, "oam.custom.navmenu.jscookmenu", MYFACES_HACK_SCRIPT);
+            }
+            else
+            {
+                TomahawkResourceUtils.addOutputScriptResource(context, javascriptLibrary, JSCOOK_MENU_SCRIPT);
+                TomahawkResourceUtils.addOutputScriptResource(context, javascriptLibrary, JSCOOK_EFFECT_SCRIPT);
+                TomahawkResourceUtils.addOutputScriptResource(context, javascriptLibrary, MYFACES_HACK_SCRIPT);
+            }
         }
 
-        addThemeSpecificResources(themeName, styleLocation, javascriptLocation, imageLocation, context);
+        addThemeSpecificResources(themeName, styleLocation, javascriptLocation, imageLocation, 
+                styleLibrary, javascriptLibrary, imageLibrary, context);
     }
 
     /**
@@ -480,7 +494,9 @@ public class HtmlJSCookMenuRenderer
      * @param context            is the current faces context.
      */
     private void addThemeSpecificResources(String themeName, String styleLocation,
-                                           String javascriptLocation, String imageLocation, FacesContext context) {
+                                           String javascriptLocation, String imageLocation,
+                                           String styleLibrary, String javascriptLibrary,
+                                           String imageLibrary, FacesContext context) {
         String themeLocation = (String) builtInThemes.get(themeName);
         if (themeLocation == null) {
             log.debug("Unknown theme name '" + themeName + "' specified.");
@@ -503,6 +519,8 @@ public class HtmlJSCookMenuRenderer
             if (imageLocation != null) {
                 buf.append(externalContext.encodeResourceURL(addResource.getResourceUri(context,
                                                                                         imageLocation + "/" + themeName)));
+                buf.append("';");
+                addResource.addInlineScriptAtPosition(context, AddResource.HEADER_BEGIN, buf.toString());
             }
             else {
                 //buf.append(externalContext.encodeResourceURL(addResource.getResourceUri(context,
@@ -510,16 +528,27 @@ public class HtmlJSCookMenuRenderer
                 Resource resource = context.getApplication().getResourceHandler().
                     createResource(";j","oam.custom.navmenu.jscookmenu."+themeName);
                 buf.append(resource.getRequestPath());
+                buf.append("';");
+                TomahawkResourceUtils.addInlineOutputScriptResource(context, TomahawkResourceUtils.HEAD_LOCATION, buf.toString());
             }
-            buf.append("';");
-            addResource.addInlineScriptAtPosition(context, AddResource.HEADER_BEGIN, buf.toString());
         }
         else
         {
-            
+            if ((imageLibrary != null))
+            {
+                StringBuffer buf = new StringBuffer();
+                buf.append("var my");
+                buf.append(themeName);
+                buf.append("Base='");
+                Resource resource = context.getApplication().getResourceHandler().
+                    createResource(";j",imageLibrary+'.'+themeName);
+                buf.append(resource.getRequestPath());
+                buf.append("';");
+                //addResource.addInlineScriptAtPosition(context, AddResource.HEADER_BEGIN, buf.toString());
+                TomahawkResourceUtils.addInlineOutputScriptResource(context, TomahawkResourceUtils.HEAD_LOCATION, 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
@@ -539,6 +568,13 @@ public class HtmlJSCookMenuRenderer
                 TomahawkResourceUtils.addOutputScriptResource(context, "oam.custom.navmenu.jscookmenu."+themeName, "theme.js");
             }
         }
+        else
+        {
+            if ((javascriptLibrary != null))
+            {
+                TomahawkResourceUtils.addOutputScriptResource(context, javascriptLibrary+'.'+themeName, "theme.js");
+            }
+        }
 
         if ((styleLocation != null) || (themeLocation != null)) {
             // Generate a <link type="text/css"> tag in the page header pointing to
@@ -554,6 +590,13 @@ public class HtmlJSCookMenuRenderer
                 TomahawkResourceUtils.addOutputStylesheetResource(context, "oam.custom.navmenu.jscookmenu."+themeName, "theme.css");
             }
         }
+        else
+        {
+            if ((styleLibrary != null))
+            {
+                TomahawkResourceUtils.addOutputStylesheetResource(context, styleLibrary+'.'+themeName, "theme.css");
+            }
+        }
     }
 
     /**

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeImageCommandLinkRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeImageCommandLinkRenderer.java?rev=939124&r1=939123&r2=939124&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeImageCommandLinkRenderer.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeImageCommandLinkRenderer.java Wed Apr 28 22:47:01 2010
@@ -20,27 +20,31 @@ package org.apache.myfaces.custom.tree.r
 
 import java.io.IOException;
 
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
 import org.apache.myfaces.custom.tree.HtmlTreeImageCommandLink;
 import org.apache.myfaces.custom.tree.HtmlTreeNode;
 import org.apache.myfaces.renderkit.html.jsf.ExtendedHtmlLinkRenderer;
 import org.apache.myfaces.renderkit.html.util.DummyFormUtils;
+import org.apache.myfaces.shared_impl.renderkit.JSFAttr;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
 
 
 /**
- * @JSFRenderer
- *   renderKitId = "HTML_BASIC" 
- *   family = "org.apache.myfaces.HtmlTree"
- *   type = "org.apache.myfaces.HtmlTreeImageCommandLink"
  * 
  * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
  * @version $Revision: 659874 $ $Date: 2008-05-24 15:59:15 -0500 (sáb, 24 may 2008) $
  */
+@JSFRenderer(
+   renderKitId = "HTML_BASIC", 
+   family = "org.apache.myfaces.HtmlTree",
+   type = "org.apache.myfaces.HtmlTreeImageCommandLink")
 public class HtmlTreeImageCommandLinkRenderer
     extends ExtendedHtmlLinkRenderer {
 
@@ -72,6 +76,8 @@ public class HtmlTreeImageCommandLinkRen
         super.renderCommandLinkStart(facesContext, component, clientId, value, style, styleClass);
 
         String url = ((HtmlTreeImageCommandLink) component).getImage();
+        String libraryName = (String) component.getAttributes().get(JSFAttr.LIBRARY_ATTR);
+        String resourceName = (String) component.getAttributes().get(JSFAttr.NAME_ATTR);
 
         if ((url != null) && (url.length() > 0)) {
             ResponseWriter writer = facesContext.getResponseWriter();
@@ -98,5 +104,26 @@ public class HtmlTreeImageCommandLinkRen
 
             writer.endElement(HTML.IMG_ELEM);
         }
+        else if ((resourceName != null) && (resourceName.length() > 0))
+        {
+            ResponseWriter writer = facesContext.getResponseWriter();
+            writer.startElement(HTML.IMG_ELEM, component);
+            ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
+            Resource resource = null;
+            if ((libraryName != null) && (libraryName.length() > 0))
+            {
+                resource = resourceHandler.createResource(resourceName, libraryName);
+            }
+            else
+            {
+                resource = resourceHandler.createResource(resourceName);    
+            }
+            writer.writeAttribute(HTML.SRC_ATTR, resource.getRequestPath(), null);
+            writer.writeAttribute(HTML.BORDER_ATTR, ZERO, null);
+
+            HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.IMG_PASSTHROUGH_ATTRIBUTES);
+
+            writer.endElement(HTML.IMG_ELEM);
+        }
     }
 }

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java?rev=939124&r1=939123&r2=939124&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java Wed Apr 28 22:47:01 2010
@@ -18,43 +18,47 @@
  */
 package org.apache.myfaces.custom.tree.renderkit.html;
 
-import org.apache.myfaces.renderkit.html.util.AddResource;
-import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.application.Resource;
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
 import org.apache.myfaces.custom.tree.HtmlTree;
 import org.apache.myfaces.custom.tree.HtmlTreeColumn;
 import org.apache.myfaces.custom.tree.HtmlTreeImageCommandLink;
 import org.apache.myfaces.custom.tree.HtmlTreeNode;
 import org.apache.myfaces.custom.tree.IconProvider;
 import org.apache.myfaces.custom.tree.TreeNode;
+import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
 import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlTableRendererBase;
 import org.apache.myfaces.shared_tomahawk.util.ArrayUtils;
 import org.apache.myfaces.shared_tomahawk.util.StringUtils;
 
-import javax.faces.component.UIColumn;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
 /**
- * @JSFRenderer
- *   renderKitId = "HTML_BASIC" 
- *   family = "org.apache.myfaces.HtmlTree"
- *   type = "org.apache.myfaces.HtmlTree"
  * 
  * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller </a>
  * @version $Revision: 659874 $ $Date: 2008-05-24 15:59:15 -0500 (sáb, 24 may 2008) $
  */
+@JSFRenderer(
+   renderKitId = "HTML_BASIC", 
+   family = "org.apache.myfaces.HtmlTree",
+   type = "org.apache.myfaces.HtmlTree")
 public class HtmlTreeRenderer extends HtmlTableRendererBase
 {
     // Defaut images
+    private static final String DEFAULT_IMAGE_LIBRARY = "oam.custom.tree.images";
     private static final String DEFAULT_IMAGE_ICON_LINE = "images/line.gif";
     private static final String DEFAULT_IMAGE_ICON_NOLINE = "images/noline.gif";
     private static final String DEFAULT_IMAGE_ICON_CHILD_FIRST = "images/line_first.gif";
@@ -68,10 +72,25 @@ public class HtmlTreeRenderer extends Ht
     private static final String DEFAULT_IMAGE_ICON_NODE_CLOSE_FIRST = "images/node_close_first.gif";
     private static final String DEFAULT_IMAGE_ICON_NODE_CLOSE_MIDDLE = "images/node_close_middle.gif";
     private static final String DEFAULT_IMAGE_ICON_NODE_CLOSE_LAST = "images/node_close_last.gif";
+    
+    private static final String DEFAULT_RESOURCE_ICON_LINE = "line.gif";
+    private static final String DEFAULT_RESOURCE_ICON_NOLINE = "noline.gif";
+    private static final String DEFAULT_RESOURCE_ICON_CHILD_FIRST = "line_first.gif";
+    private static final String DEFAULT_RESOURCE_ICON_CHILD_MIDDLE = "line_middle.gif";
+    private static final String DEFAULT_RESOURCE_ICON_CHILD_LAST = "line_last.gif";
+    private static final String DEFAULT_RESOURCE_ICON_NODE_OPEN = "node_open.gif";
+    private static final String DEFAULT_RESOURCE_ICON_NODE_OPEN_FIRST = "node_open_first.gif";
+    private static final String DEFAULT_RESOURCE_ICON_NODE_OPEN_MIDDLE = "node_open_middle.gif";
+    private static final String DEFAULT_RESOURCE_ICON_NODE_OPEN_LAST = "node_open_last.gif";
+    private static final String DEFAULT_RESOURCE_ICON_NODE_CLOSE = "node_close.gif";
+    private static final String DEFAULT_RESOURCE_ICON_NODE_CLOSE_FIRST = "node_close_first.gif";
+    private static final String DEFAULT_RESOURCE_ICON_NODE_CLOSE_MIDDLE = "node_close_middle.gif";
+    private static final String DEFAULT_RESOURCE_ICON_NODE_CLOSE_LAST = "node_close_last.gif";
 
     private static final Integer ZERO = new Integer(0);
 
     private static final String DEFAULT_IMAGE_ICON_FOLDER = "images/folder.gif";
+    private static final String DEFAULT_RESOURCE_ICON_FOLDER = "folder.gif";
 
     public boolean getRendersChildren()
     {
@@ -361,11 +380,11 @@ public class HtmlTreeRenderer extends Ht
         }
     }
 
-    public String getDefaultImagePath(FacesContext context, String relativePathInResourceFolder)
-    {
-        AddResource instance = AddResourceFactory.getInstance(context);
-        return instance.getResourceUri(context, HtmlTree.class, relativePathInResourceFolder, false);
-    }
+    //public String getDefaultImagePath(FacesContext context, String relativePathInResourceFolder)
+    //{
+    //    AddResource instance = AddResourceFactory.getInstance(context);
+    //    return instance.getResourceUri(context, HtmlTree.class, relativePathInResourceFolder, false);
+    //}
 
     /**
      * <p>
@@ -421,6 +440,12 @@ public class HtmlTreeRenderer extends Ht
                 //writer.endElement(HTML.IMG_ELEM);
                 writeImageElement(url, facesContext, writer, child);
             }
+            else
+            {
+                String resourceName = getDefaultLayoutResourceName(facesContext, tree, state);
+                Resource resource = facesContext.getApplication().getResourceHandler().createResource(resourceName, DEFAULT_IMAGE_LIBRARY);
+                writeImageElementWithoutEncodeResourceURL(resource.getRequestPath(), facesContext, writer, child);
+            }
             writer.endElement(HTML.TD_ELEM);
 
         }
@@ -433,13 +458,34 @@ public class HtmlTreeRenderer extends Ht
         if (state == HtmlTreeNode.CHILD || state == HtmlTreeNode.CHILD_FIRST || state == HtmlTreeNode.CHILD_LAST)
         {
             // no action, just img
-            writeImageElement(url, facesContext, writer, child);
+            if ((url != null) && (url.length() > 0))
+            {
+                writeImageElement(url, facesContext, writer, child);
+            }
+            else
+            {
+                String resourceName = getDefaultLayoutResourceName(facesContext, tree, state);
+                Resource resource = facesContext.getApplication().getResourceHandler().createResource(resourceName, DEFAULT_IMAGE_LIBRARY);
+                writeImageElementWithoutEncodeResourceURL(resource.getRequestPath(), facesContext, writer, child);
+            }
         }
         else
         {
             HtmlTreeImageCommandLink expandCollapse = (HtmlTreeImageCommandLink) child
                     .getExpandCollapseCommand(facesContext);
-            expandCollapse.setImage(getLayoutImage(facesContext, tree, layout[layout.length - 1]));
+            
+            String url1 = getLayoutImage(facesContext, tree, layout[layout.length - 1]);
+            
+            if ((url1 != null) && (url1.length() > 0))
+            {
+                expandCollapse.setImage(url1);
+            }
+            else
+            {
+                String resourceName = getDefaultLayoutResourceName(facesContext, tree, layout[layout.length - 1]);
+                expandCollapse.getAttributes().put(JSFAttr.LIBRARY_ATTR, DEFAULT_IMAGE_LIBRARY);
+                expandCollapse.getAttributes().put(JSFAttr.NAME_ATTR, resourceName);
+            }
 
             expandCollapse.encodeBegin(facesContext);
             expandCollapse.encodeEnd(facesContext);
@@ -455,15 +501,15 @@ public class HtmlTreeRenderer extends Ht
         }
         else
         {
-            if (!child.isLeaf(facesContext))
-            {
+            //if (!child.isLeaf(facesContext))
+            //{
                 // todo: icon provider
-                url = getDefaultImagePath(facesContext, DEFAULT_IMAGE_ICON_FOLDER );
-            }
-            else
-            {
+                //url = getDefaultImagePath(facesContext, DEFAULT_IMAGE_ICON_FOLDER );
+            //}
+            //else
+            //{
                 url = null;
-            }
+            //}
         }
 
         if ((url != null) && (url.length() > 0))
@@ -476,6 +522,17 @@ public class HtmlTreeRenderer extends Ht
             writeImageElement(url, facesContext, writer, child);
             writer.endElement(HTML.TD_ELEM);
         }
+        else if (!child.isLeaf(facesContext) && iconProvider == null)
+        {
+            Resource resource = facesContext.getApplication().getResourceHandler().createResource(DEFAULT_RESOURCE_ICON_FOLDER, DEFAULT_IMAGE_LIBRARY);
+            writer.startElement(HTML.TD_ELEM, tree);
+            if (iconClass != null)
+            {
+                writer.writeAttribute(HTML.CLASS_ATTR, iconClass, null);
+            }
+            writeImageElementWithoutEncodeResourceURL(resource.getRequestPath(), facesContext, writer, child);
+            writer.endElement(HTML.TD_ELEM);
+        }
         else
         {
             // no icon, so label has more room
@@ -538,6 +595,16 @@ public class HtmlTreeRenderer extends Ht
 
         writer.endElement(HTML.IMG_ELEM);
     }
+    
+    private void writeImageElementWithoutEncodeResourceURL(String url, FacesContext facesContext, ResponseWriter writer, HtmlTreeNode child)
+        throws IOException
+    {
+        writer.startElement(HTML.IMG_ELEM, child);
+        writer.writeAttribute(HTML.SRC_ATTR, url, null);
+        writer.writeAttribute(HTML.BORDER_ATTR, ZERO, null);
+        HtmlRendererUtils.renderHTMLAttributes(writer, child, HTML.IMG_PASSTHROUGH_ATTRIBUTES);
+        writer.endElement(HTML.IMG_ELEM);
+    }
 
     protected String getLayoutImage(FacesContext context, HtmlTree tree, int state)
     {
@@ -573,14 +640,51 @@ public class HtmlTreeRenderer extends Ht
             return getImageUrl(context, tree.getIconNoline(), DEFAULT_IMAGE_ICON_NOLINE);
         }
     }
+    
+    protected String getDefaultLayoutResourceName(FacesContext context, HtmlTree tree, int state)
+    {
+        switch (state)
+        {
+        case HtmlTreeNode.OPEN:
+            return DEFAULT_RESOURCE_ICON_NODE_OPEN_MIDDLE;
+        case HtmlTreeNode.OPEN_FIRST:
+            return DEFAULT_RESOURCE_ICON_NODE_OPEN_FIRST;
+        case HtmlTreeNode.OPEN_LAST:
+            return DEFAULT_RESOURCE_ICON_NODE_OPEN_LAST;
+        case HtmlTreeNode.OPEN_SINGLE:
+            return DEFAULT_RESOURCE_ICON_NODE_OPEN;
+        case HtmlTreeNode.CLOSED:
+            return DEFAULT_RESOURCE_ICON_NODE_CLOSE_MIDDLE;
+        case HtmlTreeNode.CLOSED_FIRST:
+            return DEFAULT_RESOURCE_ICON_NODE_CLOSE_FIRST;
+        case HtmlTreeNode.CLOSED_LAST:
+            return DEFAULT_RESOURCE_ICON_NODE_CLOSE_LAST;
+        case HtmlTreeNode.CLOSED_SINGLE:
+            return DEFAULT_RESOURCE_ICON_NODE_CLOSE;
+        case HtmlTreeNode.CHILD:
+            return DEFAULT_RESOURCE_ICON_CHILD_MIDDLE;
+        case HtmlTreeNode.CHILD_FIRST:
+            return DEFAULT_RESOURCE_ICON_CHILD_FIRST;
+        case HtmlTreeNode.CHILD_LAST:
+            return DEFAULT_RESOURCE_ICON_CHILD_LAST;
+        case HtmlTreeNode.LINE:
+            return DEFAULT_RESOURCE_ICON_LINE;
+        case HtmlTreeNode.EMPTY:
+            return DEFAULT_RESOURCE_ICON_NOLINE;
+        default:
+            return DEFAULT_RESOURCE_ICON_NOLINE;
+        }
+    }    
 
     protected String getImageUrl(FacesContext context, String userValue, String resourceValue)
     {
-        AddResource addResource = AddResourceFactory.getInstance(context);
         if(userValue != null)
         {
+            AddResource addResource = AddResourceFactory.getInstance(context);
             return addResource.getResourceUri(context, userValue, false);
         }
-        return addResource.getResourceUri(context, HtmlTree.class, resourceValue, false);
+        // Now we use JSF 2.0 Resource api for load default resources, so we need to return null
+        //return addResource.getResourceUri(context, HtmlTree.class, resourceValue, false);
+        return null;
     }
 }

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/AbstractHtmlTree.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/AbstractHtmlTree.java?rev=939124&r1=939123&r2=939124&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/AbstractHtmlTree.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/AbstractHtmlTree.java Wed Apr 28 22:47:01 2010
@@ -27,6 +27,7 @@ import javax.faces.el.MethodBinding;
 
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
+import org.apache.myfaces.component.LibraryLocationAware;
 import org.apache.myfaces.component.LocationAware;
 
 /**
@@ -52,7 +53,7 @@ import org.apache.myfaces.component.Loca
     clazz = "org.apache.myfaces.custom.tree2.HtmlTree",
     tagClass = "org.apache.myfaces.custom.tree2.TreeTag")
 public abstract class AbstractHtmlTree extends UITreeData
-    implements LocationAware
+    implements LocationAware, LibraryLocationAware
 {
     public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlTree2";
     private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.HtmlTree2";

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java?rev=939124&r1=939123&r2=939124&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java Wed Apr 28 22:47:01 2010
@@ -640,16 +640,31 @@ public class HtmlTreeRenderer extends Re
         String javascriptLocation = ((HtmlTree) component).getJavascriptLocation();
         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");
-
-            TomahawkResourceUtils.addOutputScriptResource(context, 
-                    "oam.custom.tree2.javascript", 
-                    "tree.js");
+            String javascriptLibrary = ((HtmlTree) component).getJavascriptLibrary();
             
-            TomahawkResourceUtils.addOutputScriptResource(context, 
-                    "oam.custom.tree2.javascript", 
-                    "cookielib.js");
+            if (javascriptLibrary == null)
+            {
+                //addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlTreeRenderer.class, "javascript/tree.js");
+                //addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlTreeRenderer.class, "javascript/cookielib.js");
+    
+                TomahawkResourceUtils.addOutputScriptResource(context, 
+                        "oam.custom.tree2.javascript", 
+                        "tree.js");
+                
+                TomahawkResourceUtils.addOutputScriptResource(context, 
+                        "oam.custom.tree2.javascript", 
+                        "cookielib.js");
+            }
+            else
+            {
+                TomahawkResourceUtils.addOutputScriptResource(context, 
+                        javascriptLibrary, 
+                        "tree.js");
+                
+                TomahawkResourceUtils.addOutputScriptResource(context, 
+                        javascriptLibrary, 
+                        "cookielib.js");
+            }
         }
         else
         {
@@ -674,10 +689,19 @@ public class HtmlTreeRenderer extends Re
         String imageLocation = ((HtmlTree)component).getImageLocation();
         if (imageLocation == null)
         {
-            //return addResource.getResourceUri(context, HtmlTreeRenderer.class,
-            //        "images/" + imageName, withContextPath);
-            return TomahawkResourceUtils.getIconSrc(context, "oam.custom.tree2.images",
-                                      imageName);
+            String imageLibrary = ((HtmlTree) component).getImageLibrary();
+            if (imageLibrary == null)
+            {
+                //return addResource.getResourceUri(context, HtmlTreeRenderer.class,
+                //        "images/" + imageName, withContextPath);
+                return TomahawkResourceUtils.getIconSrc(context, "oam.custom.tree2.images",
+                                          imageName);
+            }
+            else
+            {
+                return TomahawkResourceUtils.getIconSrc(context, imageLibrary,
+                        imageName);
+            }
         }
         else
         {

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/tomahawk/util/TomahawkResourceUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/tomahawk/util/TomahawkResourceUtils.java?rev=939124&r1=939123&r2=939124&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/tomahawk/util/TomahawkResourceUtils.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/tomahawk/util/TomahawkResourceUtils.java Wed Apr 28 22:47:01 2010
@@ -25,8 +25,9 @@ import javax.faces.context.FacesContext;
 
 public class TomahawkResourceUtils
 {
-    public static String DEFAULT_SCRIPT_RENDERER_TYPE = "javax.faces.resource.Script";
-    public static String DEFAULT_STYLESHEET_RENDERER_TYPE = "javax.faces.resource.Stylesheet";
+    public static final String DEFAULT_SCRIPT_RENDERER_TYPE = "javax.faces.resource.Script";
+    public static final String DEFAULT_STYLESHEET_RENDERER_TYPE = "javax.faces.resource.Stylesheet";
+    public static final String HEAD_LOCATION = "head"; 
     
     public static void addOutputScriptResource(final FacesContext facesContext, final String libraryName, final String resourceName)
     {
@@ -65,6 +66,25 @@ public class TomahawkResourceUtils
         facesContext.getViewRoot().addComponentResource(facesContext, outputStylesheet);
     }
     
+    public static void addInlineOutputScriptResource(final FacesContext facesContext, String target, Object value)
+    {
+        UIOutput script = (UIOutput) facesContext.getApplication().createComponent(facesContext, 
+                "javax.faces.Output", "javax.faces.Text");
+        UIOutput outputScript = (UIOutput) facesContext.getApplication().
+            createComponent(facesContext, "javax.faces.Output", DEFAULT_SCRIPT_RENDERER_TYPE);
+        if (target != null)
+        {
+            script.getAttributes().put("target", target);
+        }
+        script.setValue( value);
+        script.setTransient(true);
+        script.setId(facesContext.getViewRoot().createUniqueId());
+        outputScript.getChildren().add(script);
+        outputScript.setTransient(true);
+        outputScript.setId(facesContext.getViewRoot().createUniqueId());
+        facesContext.getViewRoot().addComponentResource(facesContext, outputScript);
+    }
+    
     public static String getIconSrc(final FacesContext facesContext, final String libraryName, final String resourceName)
     {
         final ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();