You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/02/24 14:29:59 UTC

svn commit: r1293243 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/component/ tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ tobago-example/tobago-example-test/src/main/webapp/...

Author: lofwyr
Date: Fri Feb 24 13:29:58 2012
New Revision: 1293243

URL: http://svn.apache.org/viewvc?rev=1293243&view=rev
Log:
TOBAGO-986: Sheet can only sort UIOutput - Nothing happend with UILinkCommand and UIButtonCommand
 - applying last patch from bommel
 - writing a test page for sorting in the sheet

Added:
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetSortController.java
      - copied, changed from r1293134, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetController.java
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-sort.xhtml
      - copied, changed from r1293134, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-simple.xhtml
Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Sorter.java
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml
    myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js

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=1293243&r1=1293242&r2=1293243&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 Feb 24 13:29:58 2012
@@ -199,7 +199,7 @@ public class Sorter {
       if (child instanceof UISelectMany
           || child instanceof UISelectOne
           || child instanceof UISelectBoolean
-          || child instanceof AbstractUICommand
+          || (child instanceof AbstractUICommand && child.getChildren().isEmpty())
           || (child instanceof UIInput && RendererTypes.HIDDEN.equals(child.getRendererType()))) {
         continue;
         // look for a better component if any

Copied: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetSortController.java (from r1293134, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetController.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetSortController.java?p2=myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetSortController.java&p1=myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetController.java&r1=1293134&r2=1293243&rev=1293243&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetController.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetSortController.java Fri Feb 24 13:29:58 2012
@@ -17,48 +17,122 @@ package org.apache.myfaces.tobago.exampl
  * limitations under the License.
  */
 
-import org.apache.myfaces.tobago.example.data.LocaleEntry;
-import org.apache.myfaces.tobago.example.data.LocaleList;
-import org.apache.myfaces.tobago.example.data.SolarObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import javax.faces.model.DataModel;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
 
-public class SheetController {
+public class SheetSortController {
 
-  private SolarObject[] solarArray = SolarObject.getArray();
-  private SolarObject[] solarArray3 = init3();
-  private DataModel undefined = new UndefinedRowCountDataModel(solarArray3);
+  private static final Logger LOG = LoggerFactory.getLogger(SheetSortController.class);
 
-  public SheetController() {
-    init3();
+  private List<Entry> list;
+
+  public SheetSortController() {
+    init();
   }
 
-  private SolarObject[] init3() {
-    SolarObject[] help = new SolarObject[3];
-    for (int i = 0; i < 3; i++) {
-      help[i] = solarArray[i];
+  private void init() {
+    list = new ArrayList<Entry>();
+    for (int i = 0; i < 26; i++) {
+      list.add(new Entry(i));
     }
-    return help;
   }
 
-  // Create a copy for sorting, because the LocaleList.DATA is not modifiable.
-  private List<LocaleEntry> localeList = new ArrayList<LocaleEntry>(LocaleList.DATA);
-
-  public SolarObject[] getSolarArray() {
-    return solarArray;
+  public List<Entry> getList() {
+    return list;
   }
 
-  public SolarObject[] getSolarArray3() {
-    return solarArray3;
-  }
+  public static final class Entry {
+    
+    private String first;
+    private String second;
+    private String third;
+    private String fourth;
+    private Date fifth;
+    private String sixth;
+
+    private Entry(int i) {
+      this.first = "" + upper(i);
+      i++;
+      this.second = "" + upper(i) + lower(i);
+      i++;
+      this.third = "" + upper(i) + lower(i) + lower(i);
+      i++;
+      this.fourth = "" + upper(i) + lower(i) + lower(i) + lower(i);
+      i++;
+      final String dateString = "2012-02-" + i % 26;
+      try {
+        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.UK);
+        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+        this.fifth = simpleDateFormat.parse(dateString);
+      } catch (ParseException e) {
+        LOG.error("string=" + dateString, e);
+      }
+      i++;
+      this.sixth = "" + upper(i) + lower(i) + lower(i) + lower(i) + lower(i);
+    }
+    
+    private char upper(int i) {
+      return (char) (i % 26 + 'A');
+    }
 
-  public List<LocaleEntry> getLocaleList() {
-    return localeList;
-  }
+    private char lower(int i) {
+      return (char) (i % 26 + 'a');
+    }
+
+    public String getFirst() {
+      return first;
+    }
+
+    public void setFirst(String first) {
+      this.first = first;
+    }
+
+    public String getSecond() {
+      return second;
+    }
+
+    public void setSecond(String second) {
+      this.second = second;
+    }
 
-  public DataModel getUndefined() {
-    return undefined;
+    public String getThird() {
+      return third;
+    }
+
+    public void setThird(String third) {
+      this.third = third;
+    }
+
+    public String getFourth() {
+      return fourth;
+    }
+
+    public void setFourth(String fourth) {
+      this.fourth = fourth;
+    }
+
+    public Date getFifth() {
+      return fifth;
+    }
+
+    public void setFifth(Date fifth) {
+      this.fifth = fifth;
+    }
+
+    public String getSixth() {
+      return sixth;
+    }
+
+    public void setSixth(String sixth) {
+      this.sixth = sixth;
+    }
   }
 }

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml?rev=1293243&r1=1293242&r2=1293243&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml Fri Feb 24 13:29:58 2012
@@ -108,6 +108,12 @@
   </managed-bean>
 
   <managed-bean>
+    <managed-bean-name>sort</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.tobago.example.test.SheetSortController</managed-bean-class>
+    <managed-bean-scope>session</managed-bean-scope>
+  </managed-bean>
+
+  <managed-bean>
     <managed-bean-name>tree</managed-bean-name>
     <managed-bean-class>org.apache.myfaces.tobago.example.test.TreeController</managed-bean-class>
     <managed-bean-scope>session</managed-bean-scope>

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js?rev=1293243&r1=1293242&r2=1293243&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/script/tobago-assert.js Fri Feb 24 13:29:58 2012
@@ -80,6 +80,14 @@ var TobagoAssert = {
     }
   },
 
+  assertContent: function(elementOrId, expected) {
+    var element = TobagoAssert.jQueryElement(elementOrId);
+    if (element.html() != expected) {
+      LOG.error("The content of element with id=" + element.attr('id')
+          + " is '" + element.html() + "', but expected was '" + expected + "'.");
+    }
+  },
+
   /**
    * Util to get an jQuery object from a plain id string (unescaped) or a jQuery object.
    */

Copied: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-sort.xhtml (from r1293134, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-simple.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-sort.xhtml?p2=myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-sort.xhtml&p1=myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-simple.xhtml&r1=1293134&r2=1293243&rev=1293243&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-simple.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-sort.xhtml Fri Feb 24 13:29:58 2012
@@ -25,27 +25,41 @@
   <tc:page id="page">
     <tc:gridLayoutConstraint width="600px" height="600px"/>
 
-    <tc:sheet value="#{sheet.solarArray}" id="sheet" columns="*;*" var="luminary" rows="5">
-      <tc:column label="Name" id="name" sortable="true">
-        <tc:out value="#{luminary.name}"/>
+    <tc:sheet value="#{sort.list}" id="sheet" columns="*;*;*;*;*;*" var="entry">
+      <tc:column label="tc:out" id="first" sortable="true">
+        <tc:out value="#{entry.first}" id="out"/>
       </tc:column>
-      <tc:column label="Orbit Of" id="orbit">
-        <tc:out value="#{luminary.orbit}"/>
+      <tc:column label="tc:in" id="second" sortable="true">
+        <tc:in value="#{entry.second}" id="in" readonly="true"/>
+      </tc:column>
+      <tc:column label="tc:link" id="third" sortable="true">
+        <tc:link label="#{entry.third}"  id="link"/>
+      </tc:column>
+      <tc:column label="tc:button" id="fourth" sortable="true">
+        <tc:button label="#{entry.fourth}" id="button"/>
+      </tc:column>
+      <tc:column label="tc:date" id="fifth" sortable="true">
+        <tc:date value="#{entry.fifth}" id="date">
+          <f:convertDateTime timeZone="UTC" pattern="dd. MMM yyyy"/>
+        </tc:date>
+      </tc:column>
+      <tc:column label="tc:link -> tc:out" id="sixth" sortable="true">
+        <tc:link id="link2">
+          <tc:out value="#{entry.sixth}" id="out2"/>
+        </tc:link>
       </tc:column>
     </tc:sheet>
 
     <tc:script file="script/tobago-assert.js"/>
-    <!--todo-->
-    <!--<tc:script onload="TobagoAssert.assertLayout('page:todo', 0, 0, 600, 14);"/>-->
 
-    <tc:script>
-      jQuery(document).ready(function() {
-        jQuery("td>span").css("background-color", "white");
-        jQuery("td:odd").css("background-color", "#ffbbff");
-        jQuery("td:even").css("background-color", "#bbffbb");
-      });
+    <tc:script onload="TobagoAssert.assertContent('page:sheet:0:out', 'A');"/>
+    <tc:script onload="TobagoAssert.assertContent('page:sheet:1:out', 'B');"/>
+
+<!--
+    <tc:script onload="jQuery(Tobago.Utils.escapeClientId('page:sheet::header_box_0')).parent().click();"/>
+-->
+
 
-    </tc:script>
 
   </tc:page>
 </f:view>