myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gcrawf...@apache.org
Subject svn commit: r1291443 - in /myfaces/trinidad/trunk: trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/ trinidad...
Date Mon, 20 Feb 2012 21:05:57 GMT
Author: gcrawford
Date: Mon Feb 20 21:05:57 2012
New Revision: 1291443

URL: http://svn.apache.org/viewvc?rev=1291443&view=rev
Log:
TRINIDAD-2202 Support case insensitive sort

Thanks to Jing

Added:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortStrength.java
Modified:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/TableUtils.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortCriterion.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java
    myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
    myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/model/SortableModelTest.java
    myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Column.xml
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/TableRenderer.java

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/TableUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/TableUtils.java?rev=1291443&r1=1291442&r2=1291443&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/TableUtils.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/TableUtils.java
Mon Feb 20 21:05:57 2012
@@ -32,8 +32,10 @@ import org.apache.myfaces.trinidad.event
 import org.apache.myfaces.trinidad.event.RowDisclosureEvent;
 import org.apache.myfaces.trinidad.event.SelectionEvent;
 import org.apache.myfaces.trinidad.event.SortEvent;
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.model.ModelUtils;
 import org.apache.myfaces.trinidad.model.RowKeySet;
+import org.apache.myfaces.trinidad.model.SortStrength;
 import org.apache.myfaces.trinidad.model.TreeModel;
 
 /**
@@ -288,6 +290,60 @@ public final class TableUtils 
   }
   
   /**
+   * Retrieves the sort strength for the column with the given sort property from the given
table.
+   * @param parent the Collection object whose columns are searched for matching sortProperty
and retrieving
+   * sort strength from.
+   * @param sortProperty sort property value to match against column's sortProperty property.
+   * @return sort strength for the column with the given sort property from the given table.
+   */
+  public static SortStrength findSortStrength(UIXCollection parent, String sortProperty)
+  {
+    SortStrength sortStrength = null;
+
+    if (sortProperty == null || sortProperty.isEmpty())
+      return null;
+
+    List<UIComponent> children = parent.getChildren();
+    for (UIComponent child : children)
+    {
+      if (child instanceof UIXColumn)
+      {
+        UIXColumn targetColumn = (UIXColumn)child;
+        if (sortProperty.equals(targetColumn.getSortProperty()))
+        {
+          String strength = targetColumn.getSortStrength();
+          sortStrength = _toSortStrength(strength);
+          break;
+        }
+      }
+    }
+
+    return sortStrength;
+  }
+
+  /**
+   * Convert the string value of sort strength to the SortStrength type.
+   */
+  private static SortStrength _toSortStrength(String strength)
+  {
+    SortStrength sortStrength = null;
+
+    if (strength != null && !strength.isEmpty())
+    {
+      try
+      {
+        sortStrength = SortStrength.valueOf(strength.toUpperCase());
+      }
+      catch (IllegalArgumentException iae)
+      {
+         _LOG.warning("INVALID_SORT_STRENGTH_PROPERTY", strength);
+      }
+    }
+
+    return sortStrength;
+  }
+
+  /**
    * Process all the children of the given table
    */
   @SuppressWarnings("unchecked")
@@ -376,4 +432,6 @@ public final class TableUtils 
   private TableUtils()
   {
   }
+
+  private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(TableUtils.class);
 }

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortCriterion.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortCriterion.java?rev=1291443&r1=1291442&r2=1291443&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortCriterion.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortCriterion.java
Mon Feb 20 21:05:57 2012
@@ -22,20 +22,48 @@ import java.io.Serializable;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 
 /**
- * This class pairs together a property and a direction by which a 
+ * This class bundles together a property, a direction and strength by which a 
  * CollectionModel can be sorted.
  * @see CollectionModel#getSortCriteria
  */
 public class SortCriterion implements Serializable
 {
-  public SortCriterion(String property, boolean isAscending)
+  /**
+   * Construct SortCriterion instance by the given property and sort direction, 
+   * using default Identical sort strength.
+   * @param property sort property, name of the model that will be sorted on.
+   * @param isAscending whether to sort the property in ascending order or not.
+   */
+  public SortCriterion(
+    String  property,
+    boolean isAscending)
+  {
+    this(property, isAscending, SortStrength.IDENTICAL);
+  }
+
+  /**
+   * Construct SortCriterion instance by the given property, sort direction, 
+   * and sort strength.
+   * @param property sort property, name of the model that will be sorted on.
+   * @param isAscending whether to sort the property in ascending order or not.
+   * @param sortStrength sort strength value when performing sort.
+   */
+  public SortCriterion(
+    String       property,
+    boolean      isAscending,
+    SortStrength sortStrength)
   {
     if (property == null)
       throw new NullPointerException(_LOG.getMessage(
         "NULL_PROPERTY"));
 
+    if (sortStrength == null)
+      throw new NullPointerException(_LOG.getMessage(
+        "NULL_SORT_STRENGTH"));
+
     _property = property;
     _sortOrder = isAscending;
+    _sortStrength = sortStrength;
   }
 
   /**
@@ -61,6 +89,16 @@ public class SortCriterion implements Se
     return _property;
   }
 
+  /**
+   * Gets the sort strenght of this sort criterion. It controls how this column
+   * should be sorted, what level of difference considered significant during
+   * comparison.
+   */
+  public SortStrength getSortStrength()
+  {
+    return _sortStrength;
+  }
+
   @Override
   public boolean equals(Object obj)
   {
@@ -71,7 +109,8 @@ public class SortCriterion implements Se
     {
       SortCriterion that = (SortCriterion) obj;
       return (this.getProperty().equals(that.getProperty())) &&
-        (this.isAscending() == that.isAscending());
+        (this.isAscending() == that.isAscending()) && 
+        (this.getSortStrength() == that.getSortStrength());
     }
 
     return false;
@@ -81,11 +120,13 @@ public class SortCriterion implements Se
   public int hashCode()
   {
     int hc = getProperty().hashCode();
+    hc = hc * 37 + _sortStrength.hashCode();
     return isAscending() ? hc : -hc;
   }
   
   private final String _property;
   private final boolean _sortOrder;
+  private final SortStrength _sortStrength;
   private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(
     SortCriterion.class);
 

Added: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortStrength.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortStrength.java?rev=1291443&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortStrength.java
(added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortStrength.java
Mon Feb 20 21:05:57 2012
@@ -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.trinidad.model;
+
+import java.text.Collator;
+
+/**
+ * This class provides an enumeration to work with the integer values of the
+ * {@link Collator} strength values.
+ */
+public enum SortStrength
+{
+  /** @see Collator#IDENTICAL */
+  IDENTICAL(Collator.IDENTICAL),
+  /** @see Collator#PRIMARY */
+  PRIMARY(Collator.PRIMARY),
+  /** @see Collator#SECONDARY */
+  SECONDARY(Collator.SECONDARY),
+  /** @see Collator#TERTIARY */
+  TERTIARY(Collator.TERTIARY);
+
+  private SortStrength(int strength)
+  {
+    _strength = strength;
+  }
+
+  /**
+   * retrieves the strength, the integer strength value matches that of the {@link Collator}
+   * @return strength value which matches {@link Collator} strength values.
+   */
+  public int getStrength()
+  {
+    return _strength;
+  }
+
+  private final int _strength;
+}

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java?rev=1291443&r1=1291442&r2=1291443&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java
Mon Feb 20 21:05:57 2012
@@ -294,8 +294,9 @@ public class SortableModel extends Colle
       SortCriterion sc = criteria.get(0);
       if ((_sortCriterion == null) || (!_sortCriterion.equals(sc)))
       {
+        // cache the latest sort criterion and do the sorting.
         _sortCriterion = sc;
-        _sort(_sortCriterion.getProperty(), _sortCriterion.isAscending());
+        _sort(_sortCriterion);
       }
     }
   }
@@ -345,7 +346,7 @@ public class SortableModel extends Colle
 
     if (_sortCriterion != null && propertyName.equals(_sortCriterion.getProperty()))
     {
-      _sort(_sortCriterion.getProperty(), _sortCriterion.isAscending());
+      _sort(_sortCriterion);
     }
   }
 
@@ -399,24 +400,13 @@ public class SortableModel extends Colle
 
   /**
    * Sorts the underlying collection by the given property, in the
-   * given direction.
-   * @param property The name of the property to sort by. The value of this
-   * property must implement java.lang.Comparable.
-   * @param isAscending true if the collection is to be sorted in
-   * ascending order.
+   * given direction, with the given strength.
+   * @param sortCriterion sort criterion controlling sort behavior.
    * @todo support -1 for rowCount
    */
-  private void _sort(String property, boolean isAscending)
+  private void _sort(SortCriterion sortCriterion)
   {
-//    if (property.equals(_sortBy) && (isAscending == _sortOrder))
-//    {
-//      return;
-//    }
-//
-//    _sortBy = property;
-//    _sortOrder = isAscending;
-
-      //TODO: support -1 for rowCount:
+    //TODO: support -1 for rowCount:
     int sz = getRowCount();
     if ((_baseIndicesList == null) || (_baseIndicesList.size() != sz))
     {
@@ -441,8 +431,9 @@ public class SortableModel extends Colle
       ELContext elContext = _getELContext(context, resolver);
       Locale locale = _getLocale(rc, context);
       Comparator<Integer> comp =
-        new Comp(resolver, elContext, locale, property);
-      if (!isAscending)
+        new Comp(resolver, elContext, locale, sortCriterion.getProperty(),
+                 sortCriterion.getSortStrength());
+      if (!sortCriterion.isAscending())
         comp = new Inverter<Integer>(comp);
 
       Collections.sort(_baseIndicesList, comp);
@@ -525,17 +516,26 @@ public class SortableModel extends Colle
   private final class Comp implements Comparator<Integer>
   {
     public Comp(
-      ELResolver resolver,
-      ELContext  context,
-      Locale     locale,
-      String     property)
+      ELResolver   resolver,
+      ELContext    context,
+      Locale       locale,
+      String       property,
+      SortStrength sortStrength)
     {
       _resolver = resolver;
       _context  = context;
 
-      if (locale != null)
+      // use Collator as comparator whenever locale or strength is available,
+      // so sorting is natural to that locale.
+      if (locale != null || sortStrength != null)
       {
-        _collator = Collator.getInstance(locale);
+        if (locale != null)
+          _collator = Collator.getInstance(locale);
+        else
+          _collator = Collator.getInstance();
+
+        if (sortStrength != null)
+          _collator.setStrength(sortStrength.getStrength());
       }
       else
       {

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts?rev=1291443&r1=1291442&r2=1291443&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
Mon Feb 20 21:05:57 2012
@@ -362,6 +362,12 @@
  
  <!-- NULL_PROPERTY -->
  <resource key="NULL_PROPERTY">property is null</resource>
+
+ <!-- NULL_SORT_STRENGTH -->
+ <resource key="NULL_SORT_STRENGTH">sort strength is null</resource>
+
+ <!-- INVALID_SORT_STRENGTH_PROPERTY -->
+ <resource key="INVALID_SORT_STRENGTH_PROPERTY">Invalid sortStrength property value:
{0}. The supported values are Primary, Secondary, Tertiary and Identical.</resource>
  
  <!-- NO_MENUCONTENTHANDLER_REGISTERED -->
  <resource key="NO_MENUCONTENTHANDLER_REGISTERED">No MenuContentHandler was registered.</resource>

Modified: myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/model/SortableModelTest.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/model/SortableModelTest.java?rev=1291443&r1=1291442&r2=1291443&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/model/SortableModelTest.java
(original)
+++ myfaces/trinidad/trunk/trinidad-api/src/test/java/org/apache/myfaces/trinidad/model/SortableModelTest.java
Mon Feb 20 21:05:57 2012
@@ -73,6 +73,10 @@ public class SortableModelTest extends A
     assertTrue(sModel.getRowData() == _bean2);
     sModel.setRowIndex(2);
     assertTrue(sModel.getRowData() == _bean3);
+    sModel.setRowIndex(3);
+    assertTrue(sModel.getRowData() == _bean4);
+    sModel.setRowIndex(4);
+    assertTrue(sModel.getRowData() == _bean5);
   }
   
   public void testRowCount()
@@ -93,7 +97,7 @@ public class SortableModelTest extends A
     assertFalse(sModel.isSortable("object"));
   }
 
-  public void testSortAscending()
+  public void testSortAscendingDefault()
   {
     DataModel dModel = _createTestDataModel();
     SortableModel sModel = new SortableModel(dModel);
@@ -109,11 +113,51 @@ public class SortableModelTest extends A
     sModel.setRowIndex(0);
     assertTrue(sModel.getRowData() == _bean2);
     sModel.setRowIndex(1);
-    assertTrue(sModel.getRowData() == _bean1);
+    assertTrue(sModel.getRowData() == _bean5);
     sModel.setRowIndex(2);
+    assertTrue(sModel.getRowData() == _bean4);
+    sModel.setRowIndex(3);
+    assertTrue(sModel.getRowData() == _bean1);
+    sModel.setRowIndex(4);
     assertTrue(sModel.getRowData() == _bean3);
   }
   
+  public void testSortAscendingCaseInsensitive()
+  {
+    DataModel dModel = _createTestDataModel();
+    SortableModel sModel = new SortableModel(dModel);
+    _sort(sModel, "name", true, "Primary");    
+
+    sModel.setRowIndex(0);
+    assertTrue(sModel.getRowData() == _bean2);
+    sModel.setRowIndex(1);
+    assertTrue(sModel.getRowData() == _bean5);
+    sModel.setRowIndex(2);
+    assertTrue(sModel.getRowData() == _bean4);
+    sModel.setRowIndex(3);
+    assertTrue(sModel.getRowData() == _bean1);
+    sModel.setRowIndex(4);
+    assertTrue(sModel.getRowData() == _bean3);
+  }
+
+  public void testSortAscendingCaseSensitive()
+  {
+    DataModel dModel = _createTestDataModel();
+    SortableModel sModel = new SortableModel(dModel);
+    _sort(sModel, "name", true, "Identical");    
+
+    sModel.setRowIndex(0);
+    assertTrue(sModel.getRowData() == _bean2);
+    sModel.setRowIndex(1);
+    assertTrue(sModel.getRowData() == _bean5);
+    sModel.setRowIndex(2);
+    assertTrue(sModel.getRowData() == _bean4);
+    sModel.setRowIndex(3);
+    assertTrue(sModel.getRowData() == _bean1);
+    sModel.setRowIndex(4);
+    assertTrue(sModel.getRowData() == _bean3);
+  }
+
   public void testUnsort()
   {
     DataModel dModel = _createTestDataModel();
@@ -132,8 +176,12 @@ public class SortableModelTest extends A
     sModel.setRowIndex(0);
     assertTrue(sModel.getRowData() == _bean2);
     sModel.setRowIndex(1);
-    assertTrue(sModel.getRowData() == _bean3);
+    assertTrue(sModel.getRowData() == _bean5);
     sModel.setRowIndex(2);
+    assertTrue(sModel.getRowData() == _bean3);
+    sModel.setRowIndex(3);
+    assertTrue(sModel.getRowData() == _bean4);
+    sModel.setRowIndex(4);
     assertTrue(sModel.getRowData() == _bean1);
   }
   
@@ -153,11 +201,15 @@ public class SortableModelTest extends A
     _sort(sModel, "age", true);    
 
     dModel.setRowIndex(2); //Zach
-    assertTrue(sModel.getRowIndex() == 1);
+    assertTrue(sModel.getRowIndex() == 2);
     dModel.setRowIndex(0); //Tracy
     assertTrue(sModel.getRowIndex() == 0);
-    dModel.setRowIndex(1); //Anne
-    assertTrue(sModel.getRowIndex() == 2);
+    dModel.setRowIndex(4); //ANNE
+    assertTrue(sModel.getRowIndex() == 3);
+    dModel.setRowIndex(3); //timmy
+    assertTrue(sModel.getRowIndex() == 1);
+    dModel.setRowIndex(1); //anne
+    assertTrue(sModel.getRowIndex() == 4);
   }
 
   public void testSetRowIndex()
@@ -166,11 +218,15 @@ public class SortableModelTest extends A
     SortableModel sModel = new SortableModel(dModel);
     _sort(sModel, "age", true);    
 
-    sModel.setRowIndex(1); //Zach
+    sModel.setRowIndex(2); //Zach
     assertTrue(dModel.getRowIndex() == 2);
     sModel.setRowIndex(0); //Tracy
     assertTrue(dModel.getRowIndex() == 0);
-    sModel.setRowIndex(2); //Anne
+    sModel.setRowIndex(3); //ANNE
+    assertTrue(dModel.getRowIndex() == 4);
+    sModel.setRowIndex(1); //timmy
+    assertTrue(dModel.getRowIndex() == 3);
+    sModel.setRowIndex(4); //anne
     assertTrue(dModel.getRowIndex() == 1);
   }
   
@@ -180,19 +236,43 @@ public class SortableModelTest extends A
     list.add(_bean1);
     list.add(_bean2);
     list.add(_bean3);
+    list.add(_bean4);
+    list.add(_bean5);
     return new ListDataModel(Collections.unmodifiableList(list));
   }
 
-  private void _sort(CollectionModel model, 
-                     String property, boolean isAscending)
+  private void _sort(
+    CollectionModel model, 
+    String          property,
+    boolean         isAscending)
+  {
+    _sort(model, property, isAscending, null);
+  }
+
+  private void _sort(
+    CollectionModel model, 
+    String          property,
+    boolean         isAscending,
+    String          strength)
   {
-    SortCriterion criterion = new SortCriterion(property, isAscending);
+    SortStrength sortStrength = null;
+
+    if (strength != null)
+    {
+      sortStrength = SortStrength.valueOf(strength.toUpperCase());
+    }
+
+    SortCriterion criterion = sortStrength == null ?
+                              new SortCriterion(property, isAscending) :
+                              new SortCriterion(property, isAscending, sortStrength);
     model.setSortCriteria(Collections.singletonList(criterion));
   }
   
   private final Bean _bean1 = new Bean(10, "Tracy");
-  private final Bean _bean2 = new Bean(15, "Anne");
+  private final Bean _bean2 = new Bean(15, "anne");
   private final Bean _bean3 = new Bean(12, "Zach");
+  private final Bean _bean4 = new Bean(11, "timmy");
+  private final Bean _bean5 = new Bean(14, "ANNE");
   
   public static final class Bean
   {

Modified: myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Column.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Column.xml?rev=1291443&r1=1291442&r2=1291443&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Column.xml
(original)
+++ myfaces/trinidad/trunk/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Column.xml
Mon Feb 20 21:05:57 2012
@@ -71,6 +71,23 @@
         </fmd:property-metadata>
       </property-extension>
     </property>
+    <property>
+      <description><![CDATA[The sorting strength for this column. It controls how
this column should
+      be sorted, what level of difference considered significant during comparison. Currently
the
+      values supported are: "Primary", "Secondary", "Tertiary" and "Identical". Default value
is
+      "Identical".]]>
+      </description>
+      <property-name>sortStrength</property-name>
+      <property-class>java.lang.String</property-class>
+      <default-value>Identical</default-value>
+      <property-extension>
+        <mfp:property-metadata/>
+        <fmd:property-metadata>
+          <fmd:required>false</fmd:required>
+          <fmd:property-values>Primary Secondary Tertiary Identical</fmd:property-values>
+        </fmd:property-metadata>
+      </property-extension>
+    </property>
     <component-extension>
       <mfp:component-family>org.apache.myfaces.trinidad.Column</mfp:component-family>
       <mfp:component-supertype>org.apache.myfaces.trinidad.ComponentBase</mfp:component-supertype>

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/TableRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/TableRenderer.java?rev=1291443&r1=1291442&r2=1291443&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/TableRenderer.java
(original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/TableRenderer.java
Mon Feb 20 21:05:57 2012
@@ -54,6 +54,7 @@ import org.apache.myfaces.trinidad.event
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.model.RowKeySet;
 import org.apache.myfaces.trinidad.model.SortCriterion;
+import org.apache.myfaces.trinidad.model.SortStrength;
 import org.apache.myfaces.trinidad.render.ClientRowKeyManager;
 import org.apache.myfaces.trinidad.render.CoreRenderer;
 import org.apache.myfaces.trinidad.util.IntegerUtils;
@@ -244,7 +245,8 @@ abstract public class TableRenderer exte
     String property = parameters.get(XhtmlConstants.VALUE_PARAM);
     Object state = parameters.get(XhtmlConstants.STATE_PARAM);
     boolean sortOrder = !XhtmlConstants.SORTABLE_ASCENDING.equals(state);
-    SortCriterion criterion = new SortCriterion(property, sortOrder);
+    SortStrength sortStrength = TableUtils.findSortStrength(table, property);
+    SortCriterion criterion = new SortCriterion(property, sortOrder, sortStrength);
 
     SortEvent event =
       new SortEvent(table, Collections.singletonList(criterion));



Mime
View raw message