incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awi...@apache.org
Subject svn commit: r431927 - in /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal: renderkit/core/xhtml/FormData.java renderkit/htmlBasic/HtmlCommandButtonRenderer.java skin/SkinStyleSheetParserUtils.java
Date Wed, 16 Aug 2006 15:45:34 GMT
Author: awiner
Date: Wed Aug 16 08:45:33 2006
New Revision: 431927

URL: http://svn.apache.org/viewvc?rev=431927&view=rev
Log:
Final patch for ADFFACES-121:  full support for url() properties in skinning;  plus a couple
of other Java 5 patches (all from Simon)

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormData.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/htmlBasic/HtmlCommandButtonRenderer.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormData.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormData.java?rev=431927&r1=431926&r2=431927&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormData.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormData.java
Wed Aug 16 08:45:33 2006
@@ -492,7 +492,7 @@
     if (libURI != null)
     {
       // check if it's already been written
-      Map props = rc.getProperties();
+      Map<Object, Object> props = rc.getProperties();
       if( props.get(libURI) == null)
       {        
         // put the lib name in the property map so it won't be written out again

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/htmlBasic/HtmlCommandButtonRenderer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/htmlBasic/HtmlCommandButtonRenderer.java?rev=431927&r1=431926&r2=431927&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/htmlBasic/HtmlCommandButtonRenderer.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/htmlBasic/HtmlCommandButtonRenderer.java
Wed Aug 16 08:45:33 2006
@@ -22,6 +22,8 @@
   {
   }
 
+  @SuppressWarnings("unchecked")
+  @Override
   public void encodeBegin(FacesContext context, 
                           UIComponent component)
     throws IOException
@@ -31,7 +33,7 @@
       return;
     }
     
-    Map attrs = component.getAttributes();
+    Map<String, Object> attrs = component.getAttributes();
     UICommand command = (UICommand) component;
     // Which button type (SUBMIT, RESET, or BUTTON) should we generate?
     String type = (String) attrs.get("type");
@@ -85,6 +87,7 @@
     writer.endElement("input");
   }
 
+  @Override
   public void decode(FacesContext context, UIComponent component)
   {
     Object source =
@@ -98,7 +101,10 @@
     }
   }
 
-  private void _writeBooleanPassThruAttr(ResponseWriter out, Map attrs, String key)
+  private void _writeBooleanPassThruAttr(
+      ResponseWriter out, 
+      Map<String, Object> attrs, 
+      String key)
     throws IOException
   {
     Object value = attrs.get(key);
@@ -108,7 +114,10 @@
     }
   }
 
-  private void _writePassThruAttrs(ResponseWriter out, Map attrs, String[] keys)
+  private void _writePassThruAttrs(
+      ResponseWriter out, 
+      Map<String, Object> attrs, 
+      String[] keys)
     throws IOException
   {
     for(int i=0; i<keys.length; i++)

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java?rev=431927&r1=431926&r2=431927&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
Wed Aug 16 08:45:33 2006
@@ -362,7 +362,7 @@
         }
         else if(propertyValue != null)
         {
-          if(_isURLValue(propertyValue))
+          if(_containsURL(propertyValue))
           {
             String resolvedUrl = _resolveURL(baseURI,
                                              propertyValue,
@@ -403,50 +403,83 @@
       String sourceName,
       String selectorName)
   {
-    String uri = _getURIString(url);
-    if(uri.length() == 0)
+    int endIndex = -1;
+    int index = url.indexOf("url(");
+    StringBuilder builder = new StringBuilder();
+    builder.append(url, 0 , index);
+    while(index >= 0)
     {
-      // url() or url('') found, should not happen.
-      _LOG.warning("An empty URL was found in selector '" +
-                   selectorName +
-                   "' in style sheet '" +
-                   sourceName + "'.");
+      // Appends values before url()
+      builder.append(url, endIndex + 1, index);
       
-      return url;
-    }
-    
-    if(uri.charAt(0) == '/')
-    {
-      // A transformation is required
-      if(uri.length() > 1 && uri.charAt(1) == '/')
+      endIndex = url.indexOf(')', index + 3);
+      String uri = url.substring(index + 4, endIndex);
+      if(uri.length() == 0)
       {
-        // Double slashes, trim one and do not add context root before
-        return "url(" + uri.substring(1) + ")";
+        // url() or url('') found, should not happen.
+        _LOG.warning("An empty URL was found in selector '" +
+                     selectorName +
+                     "' in style sheet '" +
+                     sourceName + "'.");
       }
-      else
+      
+      if(uri.charAt(0) == '/')
       {
-        // Single slash, add context path.
-        FacesContext facesContext = FacesContext.getCurrentInstance();
-        assert(facesContext != null);
-
-        ExternalContext externalContext = facesContext.getExternalContext();
-        String contextPath = externalContext.getRequestContextPath();
-        assert(contextPath.charAt(0) == '/');
-        assert(contextPath.charAt(contextPath.length() - 1) != '/');
-        
-        return "url(" + contextPath + uri + ")";
-      }
-    }
-    else if(_isRelativeURI(uri))
-    {
-      // Convert relative URL values to absolute, since
-      // relative values will be resolved relative to the
-      // generated style sheet, not the source CSS file.
-      return _getAbsoluteURLValue(baseUrl, uri, sourceName, selectorName);
+        // A transformation is required
+        if(uri.length() > 1 && uri.charAt(1) == '/')
+        {
+          // Double slashes, trim one and do not add context root before
+          builder.append("url(");
+          builder.append(uri, 1, uri.length());
+          builder.append(')');
+        }
+        else
+        {
+          // Single slash, add context path.
+          FacesContext facesContext = FacesContext.getCurrentInstance();
+          assert(facesContext != null);
+
+          ExternalContext externalContext = facesContext.getExternalContext();
+          String contextPath = externalContext.getRequestContextPath();
+          builder.append("url(");
+          
+          assert contextPath.charAt(0) == '/';
+          //if(contextPath.charAt(0) != '/')
+          //{
+          //  // Should not happen, but never too prudent
+          //  builder.append('/');
+          //}
+          
+          assert contextPath.charAt(contextPath.length() - 1) != '/';
+          //if(contextPath.charAt(contextPath.length() - 1) == '/')
+          //{
+          //  // Should not happen, but better safe than sorry.
+          //  builder.append(contextPath, 0, contextPath.length() - 1);
+          //}
+          //else
+          //{
+          builder.append(contextPath);
+          //}
+          
+          builder.append(uri);
+          builder.append(')');
+        }
+      }
+      else if(_isRelativeURI(uri))
+      {
+        // Convert relative URL values to absolute, since
+        // relative values will be resolved relative to the
+        // generated style sheet, not the source CSS file.
+        builder.append(_getAbsoluteURLValue(baseUrl, uri, sourceName, selectorName));
+      }
+      
+      index = url.indexOf("url(", endIndex);
     }
     
+    builder.append(url, endIndex + 1, url.length());
+
     // Don't change anything
-    return url;
+    return builder.toString();
   }
 
   /**
@@ -567,7 +600,24 @@
         boolean startsWithTwoSlashes = uri.startsWith("//");
         if (!startsWithTwoSlashes && uri.startsWith("/"))
         {
-          uri = uri.substring(1);
+          // -= Simon Lessard =-
+          // Hack: URL at this point might already have been resolved.
+          //       It will be resolved if the content was specified using 
+          //       url(). If so, it need to be unresolved.
+          FacesContext    context     = FacesContext.getCurrentInstance();
+          ExternalContext eContext    = context.getExternalContext();
+          String          contextPath = eContext.getRequestContextPath();
+          assert contextPath.charAt(0) == '/';
+          assert contextPath.charAt(contextPath.length() - 1) != '/';
+          if(uri.startsWith(contextPath))
+          {
+            uri = uri.substring(contextPath.length() + 1);
+          }
+          else
+          {
+            uri = uri.substring(1);
+          }
+          
           icon =
             new ContextImageIcon(uri, uri, width, height, null, inlineStyle);
         }
@@ -921,6 +971,25 @@
     buffer.append(")");
 
     return buffer.toString();
+  }
+  
+  /**
+   * Determines if the specified value contains a CSS url. The URLs are
+   * detected but finding usage of url() function.
+   * 
+   * @param value
+   * 
+   * @return <code>true</code> if the specified value contains an URL, 
+   *         <code>false</code> otherwise.
+   */
+  private static boolean _containsURL(String value)
+  {
+    if(value == null)
+    {
+      return false;
+    }
+    
+    return value.indexOf("url(") >= 0;
   }
 
   /**



Mime
View raw message