You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2011/04/01 23:08:46 UTC

svn commit: r1087897 - /myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java

Author: bommel
Date: Fri Apr  1 21:08:46 2011
New Revision: 1087897

URL: http://svn.apache.org/viewvc?rev=1087897&view=rev
Log:
(TOBAGO-986) Sheet can only sort UIOutput - Nothing happend with UILinkCommand and UIButtonCommand
possible solution for 1.5.x

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java?rev=1087897&r1=1087896&r2=1087897&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java Fri Apr  1 21:08:46 2011
@@ -18,6 +18,7 @@ package org.apache.myfaces.tobago.compon
  */
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.myfaces.tobago.compat.FacesUtils;
@@ -40,14 +41,8 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.Iterator;
 import java.util.List;
 
-/*
- * User: weber
- * Date: Mar 7, 2005
- * Time: 4:01:27 PM
- */
 public class Sorter {
 
   private static final Logger LOG = LoggerFactory.getLogger(Sorter.class);
@@ -78,9 +73,9 @@ public class Sorter {
         UIComponent child = getFirstSortableChild(column.getChildren());
         if (child != null) {
           String var = data.getVar();
-
-          if (FacesUtils.hasValueBindingOrValueExpression(child, "value")) {
-            String expressionString = FacesUtils.getExpressionString(child, "value");
+          String attributeName = child instanceof AbstractUICommand ? "label":"value";
+          if (FacesUtils.hasValueBindingOrValueExpression(child, attributeName)) {
+            String expressionString = FacesUtils.getExpressionString(child, attributeName);
             if (isSimpleProperty(expressionString)) {
               if (expressionString.startsWith("#{")
                   && expressionString.endsWith("}")) {
@@ -198,22 +193,21 @@ public class Sorter {
   private UIComponent getFirstSortableChild(List children) {
     UIComponent child = null;
 
-    for (Iterator iter = children.iterator(); iter.hasNext();) {
-      child = (UIComponent) iter.next();
-      if (child instanceof UICommand
-          || child instanceof javax.faces.component.UIPanel) {
-        child = getFirstSortableChild(child.getChildren());
-      }
+    for (Object aChildren : children) {
+      child = (UIComponent) aChildren;
       if (child instanceof UISelectMany
           || child instanceof UISelectOne
-          || child instanceof UISelectBoolean) {
+          || child instanceof UISelectBoolean
+          || (child instanceof UIInput && RendererTypes.HIDDEN.equals(child.getRendererType()))) {
         continue;
-      } else if (child instanceof UIInput
-          && RendererTypes.HIDDEN.equals(child.getRendererType())) {
-        continue;
-      } else if (child instanceof UIOutput) {
+      }
+      if (child instanceof UIOutput || child instanceof AbstractUICommand) {
         break;
       }
+      if (child instanceof UICommand
+          || child instanceof javax.faces.component.UIPanel) {
+        child = getFirstSortableChild(child.getChildren());
+      }
     }
     return child;
   }