You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by aw...@apache.org on 2006/07/19 03:38:00 UTC

svn commit: r423354 - in /incubator/adffaces/trunk/adf-faces: adf-faces-build/src/main/resources/META-INF/maven-faces-plugin/components/adf/core/ adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/renderkit/core/xhtml/

Author: awiner
Date: Tue Jul 18 20:37:59 2006
New Revision: 423354

URL: http://svn.apache.org/viewvc?rev=423354&view=rev
Log:
ADFFACES-7: Add defaultSortOrder attribute to af:column.  Partially from a patch by Pierre-Luc Archambault

Modified:
    incubator/adffaces/trunk/adf-faces/adf-faces-build/src/main/resources/META-INF/maven-faces-plugin/components/adf/core/CoreColumn.xml
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/renderkit/core/xhtml/ColumnGroupRenderer.java

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-build/src/main/resources/META-INF/maven-faces-plugin/components/adf/core/CoreColumn.xml
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-build/src/main/resources/META-INF/maven-faces-plugin/components/adf/core/CoreColumn.xml?rev=423354&r1=423353&r2=423354&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-build/src/main/resources/META-INF/maven-faces-plugin/components/adf/core/CoreColumn.xml (original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-build/src/main/resources/META-INF/maven-faces-plugin/components/adf/core/CoreColumn.xml Tue Jul 18 20:37:59 2006
@@ -43,6 +43,19 @@
         <mfp:property-values>start end center left right</mfp:property-values>
       </property-extension>
     </property>
+
+     <property>
+      <description><![CDATA[The default sort order of the column. The legal values are "ascending" or "descending" for ascending sorting or descending sorting on a first click respectively. The default value is "ascending".]]>
+      </description>
+      <property-name>defaultSortOrder</property-name>
+      <property-class>java.lang.String</property-class>
+      <default-value>ascending</default-value>
+      <property-extension>
+        <mfp:required>false</mfp:required>
+        <mfp:property-values>ascending descending</mfp:property-values>
+      </property-extension>
+    </property>
+
     <property>
       <description><![CDATA[the preferred width of this column, e.g., "30%", "100px".]]></description>
       <property-name>width</property-name>

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/renderkit/core/xhtml/ColumnGroupRenderer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/renderkit/core/xhtml/ColumnGroupRenderer.java?rev=423354&r1=423353&r2=423354&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/renderkit/core/xhtml/ColumnGroupRenderer.java (original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/renderkit/core/xhtml/ColumnGroupRenderer.java Tue Jul 18 20:37:59 2006
@@ -73,6 +73,7 @@
     _widthKey = type.findKey("width");
     _sortableKey = type.findKey("sortable");
     _sortPropertyKey = type.findKey("sortProperty");
+    _defaultSortOrderKey = type.findKey("defaultSortOrder");
   }
 
 
@@ -150,6 +151,11 @@
     return toString(bean.getProperty(_sortPropertyKey));
   }
 
+  protected String getDefaultSortOrder(FacesBean bean)
+  {
+    return toString(bean.getProperty(_defaultSortOrderKey));
+  }
+
 
   static public String getDefaultHeaderStyleClass(TableRenderingContext tContext)
   {
@@ -465,11 +471,25 @@
     String formName = arc.getFormData().getName();
     String source   = tContext.getTableId();
     String value    = getSortProperty(bean);
-    String state = (sortability == SORT_ASCENDING)
-      ? XhtmlConstants.SORTABLE_ASCENDING
-      : (sortability == SORT_DESCENDING)
-      ? XhtmlConstants.SORTABLE_DESCENDING
-      : "";
+    // Note that "state" refers to the current state, not
+    // the state will be set after clicking
+    String state;
+    if (sortability == SORT_ASCENDING)
+    {
+      state = XhtmlConstants.SORTABLE_ASCENDING;
+    }
+    else if (sortability == SORT_DESCENDING)
+    {
+      state = XhtmlConstants.SORTABLE_DESCENDING;
+    }
+    else if ("descending".equals(getDefaultSortOrder(bean)))
+    {
+      state = XhtmlConstants.SORTABLE_ASCENDING;
+    }
+    else
+    {
+      state = "";
+    }
 
     StringBuffer buffer = new StringBuffer(33+
                                            formName.length() +
@@ -835,6 +855,7 @@
   private PropertyKey _widthKey;
   private PropertyKey _sortPropertyKey;
   private PropertyKey _sortableKey;
+  private PropertyKey _defaultSortOrderKey;
 
   private static final ADFLogger _LOG = ADFLogger.createADFLogger(ColumnGroupRenderer.class);
 }