myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r905871 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html: HtmlScriptRenderer.java HtmlStylesheetRenderer.java
Date Wed, 03 Feb 2010 02:26:05 GMT
Author: lu4242
Date: Wed Feb  3 02:26:01 2010
New Revision: 905871

URL: http://svn.apache.org/viewvc?rev=905871&view=rev
Log:
MYFACES-2507 onClick on commandLink does not trigger loading of required jsf.js

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java?rev=905871&r1=905870&r2=905871&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlScriptRenderer.java
Wed Feb  3 02:26:01 2010
@@ -44,6 +44,7 @@
 import org.apache.myfaces.shared_impl.renderkit.JSFAttr;
 import org.apache.myfaces.shared_impl.renderkit.RendererUtils;
 import org.apache.myfaces.shared_impl.renderkit.html.HTML;
+import org.apache.myfaces.shared_impl.renderkit.html.util.ResourceUtils;
 import org.apache.myfaces.view.facelets.PostBuildComponentTreeOnRestoreViewEvent;
 
 /**
@@ -60,8 +61,6 @@
 {
     //private static final Log log = LogFactory.getLog(HtmlScriptRenderer.class);
     private static final Logger log = Logger.getLogger(HtmlScriptRenderer.class.getName());
-    
-    private final static String RENDERED_RESOURCES_SET = HtmlScriptRenderer.class+".RENDERED_RESOURCES_SET";

 
     public void processEvent(ComponentSystemEvent event)
     {
@@ -110,24 +109,6 @@
         return true;
     }
 
-    /**
-     * Return a set of already rendered resources by this renderer on the current
-     * request. 
-     * 
-     * @param facesContext
-     * @return
-     */
-    protected Set<String> getRenderedResources(FacesContext facesContext)
-    {
-        Set<String> map = (Set<String>) facesContext.getAttributes().get(RENDERED_RESOURCES_SET);
-        if (map == null)
-        {
-            map = new HashSet<String>();
-            facesContext.getAttributes().put(RENDERED_RESOURCES_SET,map);
-        }
-        return map;
-    }
-    
     @Override
     public void encodeChildren(FacesContext facesContext, UIComponent component)
             throws IOException
@@ -197,14 +178,10 @@
             return;
         }
         
-        Set<String> renderedResources = getRenderedResources(facesContext);
-                
-        String resourceKey;
         Resource resource;
         if (libraryName == null)
         {
-            resourceKey = resourceName;
-            if (renderedResources.contains(resourceKey))
+            if (ResourceUtils.isRenderedScript(facesContext, libraryName, resourceName))
             {
                 //Resource already founded
                 return;
@@ -214,8 +191,7 @@
         }
         else
         {
-            resourceKey = libraryName+'/'+resourceName;
-            if (renderedResources.contains(resourceKey))
+            if (ResourceUtils.isRenderedScript(facesContext, libraryName, resourceName))
             {
                 //Resource already founded
                 return;
@@ -237,7 +213,7 @@
         else
         {
             // Rendering resource
-            renderedResources.add(resourceKey);
+            ResourceUtils.markScriptAsRendered(facesContext,  libraryName, resourceName);
             ResponseWriter writer = facesContext.getResponseWriter();
             writer.startElement(HTML.SCRIPT_ELEM, component);
             // We can't render the content type, because usually it returns "application/x-javascript"

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java?rev=905871&r1=905870&r2=905871&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlStylesheetRenderer.java
Wed Feb  3 02:26:01 2010
@@ -44,6 +44,7 @@
 import org.apache.myfaces.shared_impl.renderkit.JSFAttr;
 import org.apache.myfaces.shared_impl.renderkit.RendererUtils;
 import org.apache.myfaces.shared_impl.renderkit.html.HTML;
+import org.apache.myfaces.shared_impl.renderkit.html.util.ResourceUtils;
 import org.apache.myfaces.view.facelets.PostBuildComponentTreeOnRestoreViewEvent;
 
 /**
@@ -61,8 +62,6 @@
     //private static final Log log = LogFactory.getLog(HtmlStylesheetRenderer.class);
     private static final Logger log = Logger.getLogger(HtmlStylesheetRenderer.class.getName());
     
-    private final static String RENDERED_RESOURCES_SET = HtmlStylesheetRenderer.class+".RENDERED_RESOURCES_SET";

-
     public void processEvent(ComponentSystemEvent event)
     {
         UIComponent component = event.getComponent();
@@ -106,24 +105,6 @@
         return true;
     }
 
-    /**
-     * Return a set of already rendered resources by this renderer on the current
-     * request. 
-     * 
-     * @param facesContext
-     * @return
-     */
-    protected Set<String> getRenderedResources(FacesContext facesContext)
-    {
-        Set<String> map = (Set<String>) facesContext.getAttributes().get(RENDERED_RESOURCES_SET);
-        if (map == null)
-        {
-            map = new HashSet<String>();
-            facesContext.getAttributes().put(RENDERED_RESOURCES_SET,map);
-        }
-        return map;
-    }
-    
     @Override
     public void encodeChildren(FacesContext facesContext, UIComponent component)
             throws IOException
@@ -188,14 +169,10 @@
             return;
         }
         
-        Set<String> renderedResources = getRenderedResources(facesContext);
-                
-        String resourceKey;
         Resource resource;
         if (libraryName == null)
         {
-            resourceKey = resourceName;
-            if (renderedResources.contains(resourceKey))
+            if (ResourceUtils.isRenderedStylesheet(facesContext, libraryName, resourceName))
             {
                 //Resource already founded
                 return;
@@ -205,8 +182,7 @@
         }
         else
         {
-            resourceKey = libraryName+'/'+resourceName;
-            if (renderedResources.contains(resourceKey))
+            if (ResourceUtils.isRenderedStylesheet(facesContext, libraryName, resourceName))
             {
                 //Resource already founded
                 return;
@@ -228,7 +204,7 @@
         else
         {
             // Rendering resource
-            renderedResources.add(resourceKey);
+            ResourceUtils.markStylesheetAsRendered(facesContext, libraryName, resourceName);
             ResponseWriter writer = facesContext.getResponseWriter();
             writer.startElement(HTML.LINK_ELEM, component);
             writer.writeAttribute(HTML.REL_ATTR, HTML.STYLESHEET_VALUE,null );



Mime
View raw message