You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ct...@apache.org on 2008/04/17 00:05:49 UTC

svn commit: r648878 - in /myfaces/trinidad/trunk_1.2.x: src/site/xdoc/devguide/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/ trinidad-impl/src/main/jav...

Author: ctoth
Date: Wed Apr 16 15:05:45 2008
New Revision: 648878

URL: http://svn.apache.org/viewvc?rev=648878&view=rev
Log:
TRINIDAD-799 Add agent version support in skinning

Modified:
    myfaces/trinidad/trunk_1.2.x/src/site/xdoc/devguide/skinning.xml
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinCSSDocumentHandler.java
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetNode.java
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeParser.java
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeEqualsTest.java

Modified: myfaces/trinidad/trunk_1.2.x/src/site/xdoc/devguide/skinning.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/src/site/xdoc/devguide/skinning.xml?rev=648878&r1=648877&r2=648878&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/src/site/xdoc/devguide/skinning.xml (original)
+++ myfaces/trinidad/trunk_1.2.x/src/site/xdoc/devguide/skinning.xml Wed Apr 16 15:05:45 2008
@@ -792,7 +792,9 @@
         <li>
         <strong>@agent</strong> {/skin definitions go here/} - > 
         Possible values are: netscape, ie, mozilla, gecko, webkit (maps to safari), ice. 
-        This is to define styles only for a particular agent.          
+        This is to define styles only for a particular agent.
+        Agent type can be followed by a space separated list of version numbers.
+        Several agents can be specified separated by commas.
         </li>
         <li>
         <strong>@accessibility-profile</strong> {/skin definitions go here/} - > 
@@ -828,6 +830,12 @@
         @agent ie
         {
           af|someComponent {width: 25px; height: 10px}
+        }
+
+        /* for ie 5 and 6, we also need some margins.*/
+        @agent ie 5 6
+        {
+          af|someComponent {margin: 5px;}
         }
         
         /* The following selectors are for all platforms and all browsers */

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinCSSDocumentHandler.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinCSSDocumentHandler.java?rev=648878&r1=648877&r2=648878&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinCSSDocumentHandler.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinCSSDocumentHandler.java Wed Apr 16 15:05:45 2008
@@ -240,7 +240,7 @@
   private CompleteSelectorNode _createCompleteSelectorNode(
     String selector, 
     List<PropertyNode> propertyNodeList,
-    int[] selectorAgents,
+    Map<Integer, Set<Integer>> selectorAgents,
     int[] selectorPlatforms,
     Set<String> selectorAccProperties)
   {
@@ -291,7 +291,7 @@
     {
       // we add to the ssNodeList in this method.
       int direction = completeSelectorNode.getDirection();
-      int[] agents = completeSelectorNode.getAgents();
+      Map<Integer, Set<Integer>> agents = completeSelectorNode.getAgents();
       int[] platforms = completeSelectorNode.getPlatforms();
       Set<String> accProperties = completeSelectorNode.getAccessibilityProperties();
 
@@ -343,17 +343,27 @@
       
       if (_AT_AGENT.equals(type))
       {
-        List<Integer> list = new ArrayList<Integer>();
+        _selectorAgents = new HashMap<Integer, Set<Integer>>();
 
         for (int i=0; i < typeArray.length; i++)
         {
-          int agentInt = NameUtils.getBrowser(typeArray[i].trim());
+          //each agent specification is composed by a string identifying its type
+          //followed by space separated integers (the agent versions)
+          String[] typeAndVersions = typeArray[i].trim().split(" ");
+          int agentInt = NameUtils.getBrowser(typeAndVersions[0].trim());
           
-          if (agentInt != TrinidadAgent.APPLICATION_UNKNOWN)
-            list.add(agentInt);
+          if (agentInt != TrinidadAgent.APPLICATION_UNKNOWN) {
+            Set<Integer> versions = new HashSet<Integer>(typeAndVersions.length - 1);
+            _selectorAgents.put(agentInt, versions);
+
+            for (int j=1; j< typeAndVersions.length; j++) {
+              try {
+                versions.add(Integer.valueOf(typeAndVersions[j].trim()));
+              }
+              catch (NumberFormatException e) {}
+            }
+          }
         }
-        
-        _selectorAgents = _getIntArray(list);
       }
       else if (_AT_PLATFORM.equals(type))
       {
@@ -512,7 +522,7 @@
       String selectorName,
       List<PropertyNode> propertyNodes,
       int    direction,
-      int[]  agents,
+      Map<Integer, Set<Integer>>  agents,
       int[]  platforms,
       Set<String> accProperties
       )
@@ -521,7 +531,9 @@
       _direction = direction;
       // copy the agents and platforms because these get nulled out 
       // at the end of the @rule parsing.
-      _agents = _copyIntArray(agents);
+      _agents = agents != null
+          ? new HashMap<Integer, Set<Integer>>(agents)
+          : new HashMap<Integer, Set<Integer>>();
       _platforms = _copyIntArray(platforms);
       
       if (accProperties != null)
@@ -542,8 +554,11 @@
     {
       return _direction;
     }
-    
-    public int[] getAgents()
+
+    /**
+     * @return browser types mapped to their sets of versions
+     */
+    public Map<Integer, Set<Integer>> getAgents()
     {
       return _agents;
     }
@@ -572,7 +587,7 @@
 
     private SkinSelectorPropertiesNode _node;
     private int _direction;  // the reading direction
-    private int[] _agents;
+    private Map<Integer, Set<Integer>> _agents;
     private int[] _platforms;
     private Set<String> _accProperties;
 
@@ -593,7 +608,10 @@
   // these are the selector platform, agents and accessiblity properties of the 
   // selectors we are currently parsing in this document.
   private int[] _selectorPlatforms = null;
-  private int[] _selectorAgents = null;
+
+  //As we need to be able to have multiple versions to an agent
+  // we store a map of agents and their version sets
+  private Map<Integer, Set<Integer>> _selectorAgents = null;
 
   // Stack of accessibility property sets.  While java.util.Stack has the
   // push/pop API that we want, we don't need the synchronization, so we

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetNode.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetNode.java?rev=648878&r1=648877&r2=648878&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetNode.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetNode.java Wed Apr 16 15:05:45 2008
@@ -42,7 +42,7 @@
       List <SkinSelectorPropertiesNode> skinSelectorNodeList,
       Map<String, String> namespaceMap,
       int  direction,
-      int[] agents,
+      Map<Integer, Set<Integer>> agents,
       Set<String> accProperties
       )
     {
@@ -57,7 +57,7 @@
   SkinStyleSheetNode(
     Map<String, String> namespaceMap,
     int  direction,
-    int[] agents,
+    Map<Integer, Set<Integer>> agents,
     int[] platforms,
     Set<String> accProperties
     )
@@ -65,6 +65,7 @@
     _namespaceMap     = namespaceMap;
     _direction        = direction;
     _agents           = agents;
+    _platforms        = platforms;
     _accProperties    = accProperties;
   }     
     
@@ -101,8 +102,11 @@
     {
       return _direction;
     }
-    
-    public int[] getAgents()
+
+    /**
+     * @return a map of agent types mapped to their version sets
+     */
+    public Map<Integer, Set<Integer>> getAgents()
     {
       return _agents;
     }
@@ -119,13 +123,13 @@
 
     public boolean matches(
       int direction, 
-      int[] agents, 
+      Map<Integer, Set<Integer>> agents,
       int[] platforms,
       Set<String> accProperties)
     {
       if (direction == _direction)
       {
-        boolean agentsMatch = _intArraysEqual(agents, _agents);
+        boolean agentsMatch = _mapsEqual(agents, _agents);
         
         if (agentsMatch)
         {
@@ -160,10 +164,17 @@
       return (s1 == null) ? (s2 == null) : (s1.equals(s2));
     }
 
+    private boolean _mapsEqual(
+      Map m1,
+      Map m2)
+    {
+      return (m1 == null) ? (m2 == null) : (m1.equals(m2));
+    }
+
     private Map<String, String> _namespaceMap;
     private List <SkinSelectorPropertiesNode> _skinSelectorNodeList;
     private int  _direction;  // reading direction
-    private int[] _agents;
+    private Map<Integer, Set<Integer>> _agents;
     private int[] _platforms;
     private Set<String> _accProperties;
 }

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java?rev=648878&r1=648877&r2=648878&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleSheetParserUtils.java Wed Apr 16 15:05:45 2008
@@ -27,7 +27,6 @@
 import java.io.Reader;
 
 import java.net.URL;
-import java.net.URLConnection;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -270,7 +269,6 @@
                              null,/*locales, not yet supported*/
                              skinSSNode.getDirection(),
                              skinSSNode.getAgents(),
-                             null,/*versions, not supported*/
                              skinSSNode.getPlatforms(),
                              0,
                              skinSSNode.getAcessibilityProperties());

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java?rev=648878&r1=648877&r2=648878&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/NameUtils.java Wed Apr 16 15:05:45 2008
@@ -21,6 +21,7 @@
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Vector;
+import java.util.Set;
 
 import org.apache.myfaces.trinidadinternal.util.nls.LocaleUtils;
 import org.apache.myfaces.trinidad.util.IntegerUtils;
@@ -314,8 +315,9 @@
     int localeMatch = _isLocaleMatch(context, styleSheets);
     boolean directionMatch = _isDirectionMatch(styleSheets);
     boolean modeMatch  = _isModeMatch(styleSheets);
-    boolean browserMatch = _isBrowserMatch(context, styleSheets);
-    boolean versionMatch = _isVersionMatch(context, styleSheets);
+    boolean[] browserAndVersionMatch = _isBrowserAndVersionMatch(context, styleSheets);
+    boolean browserMatch = browserAndVersionMatch[0];
+    boolean versionMatch = browserAndVersionMatch[1];
     boolean platformMatch = _isPlatformMatch(context, styleSheets);
     boolean highContrastMatch = _isHighContrastMatch(context, styleSheets);
     boolean largeFontsMatch = _isLargeFontsMatch(context, styleSheets);
@@ -600,44 +602,40 @@
     return false;
   }
 
-  // Tests whether the browser specified in the context matches
-  // the browser variant of any matching style sheet
-  private static boolean _isBrowserMatch(StyleContext context,
+  /**
+   * Tests whether the browser specified in the context matches
+   * the browser variant of any matching style sheet
+   * @return a boolean array with the first value beeing the browser match
+   *          and the second value beeing the version match
+   */
+  private static boolean[] _isBrowserAndVersionMatch(StyleContext context,
       StyleSheetNode[] styleSheets)
   {
     int browser = context.getAgent().getAgentApplication();
+    int version = context.getAgent().getAgentMajorVersion();
     if (browser == TrinidadAgent.APPLICATION_UNKNOWN)
-      return false;
+      return new boolean[]{false, false};
 
+    boolean browserMatched = false;
     // If any style sheet has a non-null browser variant, we must
     // have a browser match.
     for (int i = 0; i < styleSheets.length; i++)
     {
-      if (!(styleSheets[i].getBrowsers().isEmpty()))
-        return true;
-    }
-
-    return false;
-  }
-
-  // Tests whether the version specified in the context matches
-  // the version variant of any matching style sheet
-  private static boolean _isVersionMatch(StyleContext context,
-      StyleSheetNode[] styleSheets)
-  {
-    int version = context.getAgent().getAgentMajorVersion();
-    if (version == 0)
-      return false;
-
-    // If any style sheet has a non-null version variant, we must
-    // have a version match.
-    for (int i = 0; i < styleSheets.length; i++)
-    {
-      if (!(styleSheets[i].getVersions().isEmpty()))
-        return true;
+      if (!(styleSheets[i].getBrowsers().isEmpty())) {
+        Set<Integer> versions
+            = styleSheets[i].getBrowsers().get(Integer.valueOf(browser));
+        if (versions != null) {
+          browserMatched = true;
+          //if this node has this version explicitly return true,true
+          //else continue searching for a node with explicit version
+          if (versions.contains(Integer.valueOf(version))) {
+            return new boolean[]{true, true};
+          }
+        }
+      }
     }
 
-    return false;
+    return new boolean[]{browserMatched, false};
   }
 
   // Tests whether the platform specified in the context matches

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java?rev=648878&r1=648877&r2=648878&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNode.java Wed Apr 16 15:05:45 2008
@@ -28,6 +28,7 @@
 
 
 import java.util.Set;
+import java.util.Map;
 
 import java.util.StringTokenizer;
 
@@ -61,8 +62,7 @@
     Collection<IconNode> icons,
     Locale[] locales,
     int direction,
-    int[] browsers,
-    int[] versions,
+    Map<Integer, Set<Integer>> browsers,
     int[] platforms,
     int mode,
     Set<String> accessibilityProperties
@@ -90,21 +90,12 @@
 
     if (browsers != null)
     {
-      Set browsersSet = _copyIntArrayToSet(browsers);
-      _browsers = Collections.unmodifiableSet(browsersSet);
+      _browsers = Collections.unmodifiableMap(browsers);
     }
     else
-      _browsers = Collections.emptySet();
+      _browsers = Collections.emptyMap();
 
 
-    if (versions != null)
-    {
-      Set versionsSet = _copyIntArrayToSet(versions);
-      _versions = Collections.unmodifiableSet(versionsSet);
-    }
-    else
-      _versions = Collections.emptySet();
-    
     if (platforms != null)
     {
       Set platformsSet = _copyIntArrayToSet(platforms);
@@ -164,22 +155,15 @@
   }
 
   /**
-   * Implementation of StyleSheetNode.getBrowsers(). 
+   * Implementation of StyleSheetNode.getBrowsers().
+   * @return a map containing each browser type mapped to its versions set
    */
-  public Collection<Integer> getBrowsers()
+  public Map<Integer, Set<Integer>> getBrowsers()
   {
     return _browsers;
   }
 
   /**
-   * Implementation of StyleSheetNode.getVersions().
-   */
-  public Collection<Integer> getVersions()
-  {
-    return _versions;
-  }
-
-  /**
    * Implementation of StyleSheetNode.getPlatforms().
    */
   public Collection<Integer> getPlatforms()
@@ -220,25 +204,14 @@
       return 0;
 
     int browser = agent.getAgentApplication();
-    int browserMatch = _compareBrowser(browser);
-    if (browserMatch == 0)
+    int version = agent.getAgentMajorVersion();
+    int browserAndVersionMatch = _compareBrowserAndVersion(browser, version);
+    if (browserAndVersionMatch == 0)
       return 0;
     int modeMatch = _compareMode(mode);
     if(modeMatch == 0)
       return 0;
-    int versionMatch = 0;
 
-    // We only consider version if browser is known.  This allows
-    // clients to generate a "default" style sheet - for cases where
-    // the browser/version isn't known.  Since there is no Agent
-    // VERSION_UNKNOWN constant, we cue off of APPLICATION_UNKNOWN.
-    if (browser != TrinidadAgent.APPLICATION_UNKNOWN)
-    {
-      versionMatch = _compareVersion(agent.getAgentMajorVersion());
-      if (versionMatch == 0)
-      return 0;
-    }
-    
     int osMatch = _compareOS(agent.getAgentOS());
     if (osMatch == 0)
       return 0;
@@ -247,7 +220,7 @@
     if (accessibilityMatch == 0)
       return 0;
 
-    return (localeMatch | browserMatch | versionMatch | osMatch | accessibilityMatch);
+    return (localeMatch | browserAndVersionMatch | osMatch | accessibilityMatch);
   }
 
   @Override  
@@ -289,14 +262,14 @@
   public String toString()
   {
     return getClass().getName() + "[" +
-      "locales="   + _locales.toString()   + ", " +
+      "locales="   + (_locales != null ? _locales.toString() : "")    + ", " +
       "direction=" + _getDirectionString() + ", " +
-      "browsers="  + _browsers.toString()  + ", " +
-      "versions="  + _versions.toString()  + ", " +
-      "platforms=" + _platforms.toString() + ", " +
-      "styles="    + _styles.toString()    + ", " +
-      "icons="     + _icons.toString()     + ", " +
-      "accessibility-profile=" + _accProps.toString() + "]";
+      "browsers="  + (_browsers != null ? _browsers.toString() : "")  + ", " +
+//      "versions="  + _versions.toString()  + ", " +
+      "platforms=" + (_platforms != null ? _platforms.toString() : "") + ", " +
+      "styles="    + (_styles != null ? _styles.toString() : "") + ", " +
+      "icons="     + (_icons != null ? _icons.toString() :"")     + ", " +
+      "accessibility-profile=" + (_accProps != null ? _accProps.toString() : "") + "]";
 
   }
 
@@ -332,7 +305,6 @@
     hash = 37*hash + _locales.hashCode();
     hash = 37*hash + _browsers.hashCode();
     hash = 37*hash + _platforms.hashCode();
-    hash = 37*hash + _versions.hashCode();
     hash = 37*hash + _styles.hashCode();
     hash = 37*hash + _accProps.hashCode();
     
@@ -398,9 +370,8 @@
     return 0;
   }
 
-  // Compares the specified browser against the supported variants
-  private int _compareBrowser(int browser)
-  {
+  //Compares the browser and its version against the supported variants
+  private int _compareBrowserAndVersion(int browser, int version) {
     // If we don't have a browser specified, we match anything
     if (_browsers.isEmpty())
       return _BROWSER_UNKNOWN_MATCH;
@@ -409,23 +380,19 @@
     // the client browser is not known, we don't have a match
     if (browser == TrinidadAgent.APPLICATION_UNKNOWN)
       return 0;
-    if (_browsers.contains(Integer.valueOf(browser)))
-      return _BROWSER_EXACT_MATCH;
+    //If we have browser exact match, compare versions
+    if (_browsers.keySet().contains(Integer.valueOf(browser))) {
+      Set<Integer> versions = _browsers.get(Integer.valueOf(browser));
+      if (versions.isEmpty())
+        return _BROWSER_EXACT_MATCH | _VERSION_UNKNOWN_MATCH;
+      if (versions.contains(Integer.valueOf(version)))
+        return _BROWSER_EXACT_MATCH | _VERSION_EXACT_MATCH;
+      return 0;
+    }
 
     return 0;
   }
 
-  // Compares the specified version against the supported variants
-  private int _compareVersion(int version)
-  {
-    if (_versions.isEmpty())
-      return _VERSION_UNKNOWN_MATCH;
-
-    if (_versions.contains(Integer.valueOf(version)))
-      return _VERSION_EXACT_MATCH;
-
-    return 0;
-  }
 
   // Compares the specified OS against the supported variants
   private int _compareOS(int os)
@@ -585,8 +552,8 @@
   // Order does not matter for locales, browsers, versions, platforms
   private final Set<Locale>     _locales;    // The locale variants
   private final int             _direction;  // The reading direction
-  private final Set<Integer>    _browsers;   // The browsers
-  private final Set<Integer>    _versions;   // The version variants
+  // The browsers mapped to their versions (multiple versions for browser supported)
+  private final Map<Integer, Set<Integer>>    _browsers;
   private final Set<Integer>    _platforms;  // The platform variants
   private final int             _mode;       // The mode  
   private final Set<String>     _accProps;   // Accessibility profile properties

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeParser.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeParser.java?rev=648878&r1=648877&r2=648878&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeParser.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeParser.java Wed Apr 16 15:05:45 2008
@@ -24,6 +24,8 @@
 import java.util.Locale;
 import java.util.Set;
 import java.util.Vector;
+import java.util.Map;
+import java.util.HashMap;
 
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
@@ -81,13 +83,27 @@
       _styles.copyInto(styles);
     }
 
+    int versionCount = (_versions != null) ? _versions.length : 0;
+
+   Set<Integer> versions = new HashSet<Integer>(versionCount);
+   for (int i=0; i < versionCount ; i++)
+     versions.add(_versions[i]);
+
+    int browserCount = (_browsers != null) ? _browsers.length : 0;
+    Map<Integer, Set<Integer>> browsers
+        = new HashMap<Integer, Set<Integer>>(browserCount);
+
+   //in XSS there's now way of having multiple browsers and multiple versions
+   //if encountered, we map all versions to each browser (it works for 1 browser)
+   for (int i=0; i < browserCount ; i++)
+     browsers.put(_browsers[i], new HashSet<Integer>(versions));
+
     return new StyleSheetNode(
         styles,
         null,      // icons only supported in skin CSS - not XSS
         _locales,
         _direction,
-        _browsers,
-        _versions,
+        browsers,
         _platforms,
         _mode,
         _accProperties

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeEqualsTest.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeEqualsTest.java?rev=648878&r1=648877&r2=648878&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeEqualsTest.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/style/xml/parse/StyleSheetNodeEqualsTest.java Wed Apr 16 15:05:45 2008
@@ -23,13 +23,12 @@
 import junit.framework.TestCase;
 
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Set;
-import java.util.Vector;
+import java.util.Map;
+import java.util.HashMap;
 
 import org.apache.myfaces.trinidad.skin.Icon;
 import org.apache.myfaces.trinidadinternal.skin.icon.ContextImageIcon;
@@ -133,13 +132,18 @@
     Locale[] anotherLocalesArray = getAnotherLocalesArray();
     Locale[] diffOrderLocalesArray = getDiffOrderLocalesArray();
      
-    // create a browsers array
-    int[] browsers = {1, 2};
-    int[] anotherBrowsers = {1, 2};
-    int[] anotherBrowsersDiffOrder = {2, 1};
-    
-    int[] versions = {6};
-    int[] anotherVersions = {6};
+    // create a browsers map
+    Map<Integer, Set<Integer>> browsers = new HashMap<Integer, Set<Integer>>();
+    browsers.put(1, new HashSet<Integer>(Arrays.asList(5, 6)));
+    browsers.put(2, new HashSet<Integer>(Arrays.asList(7, 8)));
+    Map<Integer, Set<Integer>> anotherBrowsers = new HashMap<Integer, Set<Integer>>();
+    anotherBrowsers.put(1, new HashSet<Integer>(Arrays.asList(5, 6)));
+    anotherBrowsers.put(2, new HashSet<Integer>(Arrays.asList(7, 8)));
+    Map<Integer, Set<Integer>> anotherBrowsersDiffOrder
+        = new HashMap<Integer, Set<Integer>>();
+    anotherBrowsersDiffOrder.put(2, new HashSet<Integer>(Arrays.asList(8, 7)));
+    anotherBrowsersDiffOrder.put(1, new HashSet<Integer>(Arrays.asList(6, 5)));
+
 
     int[] platforms = {2, 3, 4};
     int[] anotherPlatforms = {2, 3, 4};
@@ -155,7 +159,6 @@
     // Locale[] locales,
     // int direction,
     // int[] browsers,
-    // int[] versions,
     // int[] platforms,
     // int mode
     
@@ -164,8 +167,7 @@
                          iconNodes,
                          localesArray, 
                          0, 
-                         browsers, 
-                         versions, 
+                         browsers,
                          platforms, 
                          0,
                          accProps);
@@ -174,8 +176,7 @@
                          anotherIconNodes,
                          anotherLocalesArray,
                          0, 
-                         anotherBrowsersDiffOrder, 
-                         anotherVersions,
+                         anotherBrowsersDiffOrder,
                          anotherPlatforms, 
                          0,
                          anotherAccProps);
@@ -184,9 +185,8 @@
                          anotherIconNodes,
                          diffOrderLocalesArray,
                          0, 
-                         anotherBrowsersDiffOrder, 
-                         anotherVersions,
-                         anotherPlatforms, 
+                         anotherBrowsersDiffOrder,
+                         differentOrderPlatforms, 
                          0,
                          differentOrderAccProps);
       



Have a problem associated with radio buttons please help

Posted by "Nutulapati, Krishna" <KN...@ussco.com>.
 
Hello All,
 I need to select one among many items through radio buttons, in jsf 
 and should able to track the selected item event to identify the item 
 in the backing bean.

 The backing been has to update the item details in the panel of same 
 jsf page, and I should able to Edit  the item details and save them 
 back into the same database.

 The problem I have here is listening and capturing the events. 

 Here is the radio button code I wrote in jsf
The JSF code, I wrote is as follows. 
<h:column id="column1">

<f:facet name="header">

<h:outputText styleClass="itemListHeader" 

value="SEL" id="testRadio">




<tri:selectOneRadio 

id ="radio" required="yes"

styleClass="selectOneRadio"

valueChangeListener= "#{editItemBean.

handleRadio1ValueChange}"

immediate="true"

partialSubmit="true" 

autoSubmit = "true">

</tri:selectOneRadio >

java code is as follows

This code:
public void handleRadio1ValueChange(ValueChangeEvent valueChangedEvent)
{
               System.out.println("Value Change Event
is"+valueChangedEvent.getSource().toString());
       }

The exception I'm getting is as follows. 
javax.el.ELException: /EditItem.jsp: Bean:
com.ussco.substitution.view.bean.EditItemBean, property:
handleRadio1ValueChange
	at
com.sun.facelets.compiler.AttributeInstruction.write(AttributeInstructio
n.java:53)
	at
com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java
:39)
	at
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.jav
a:441)
	at
org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.
java:427)
	at
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.jav
a:448)
	at
org.apache.myfaces.renderkit.html.HtmlTableRendererBase.renderColumnBody
(HtmlTableRendererBase.java:195)
	at
org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeColumnChil
d(HtmlTableRendererBase.java:168)
	at
org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeInnerHtml(
HtmlTableRendererBase.java:154)
	at
org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeChildren(H
tmlTableRendererBase.java:94)
	at
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.jav
a:735)
	at
com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSuppo
rt.java:244)
	at
com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSuppo
rt.java:249)
	at
com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSuppo
rt.java:249)
	at
com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:5
94)
	at
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.
java:87)
	at
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:220)
	at
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:118)
	at
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
	at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.ja
va:966)
	at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.ja
va:907)
	at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterCh
ain.java:145)
	at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:118)
	at
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInst
anceWrapper.java:190)
	at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterCh
ain.java:130)
	at
com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterC
hain.java:87)
	at
com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilter
Manager.java:701)
	at
com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilter
Manager.java:646)
	at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrap
per.java:475)
	at
com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWr
apper.java:463)
	at
com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
	at
com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
	at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811
)
	at
com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1
433)
	at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:9
3)
	at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscriminatio
n(HttpInboundLink.java:465)
	at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformatio
n(HttpInboundLink.java:394)
	at
com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpIC
LReadCallback.java:102)
	at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(Ai
oReadCompletionListener.java:152)
	at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.
java:213)
	at
com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsync
Future.java:195)
	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
	at
com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
	at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java
:741)
	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
Please help me where I'm going wrong.