]> source.dussan.org Git - vaadin-framework.git/commitdiff
Pagelength can now be changed by extending Select. Fixes #3019
authorMarc Englund <marc.englund@itmill.com>
Wed, 27 May 2009 15:32:07 +0000 (15:32 +0000)
committerMarc Englund <marc.englund@itmill.com>
Wed, 27 May 2009 15:32:07 +0000 (15:32 +0000)
svn changeset:8035/svn branch:6.0

src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
src/com/vaadin/ui/Select.java

index 4b13c22cce06f217a5b578f9885b11adf5092733..3babf3bea4a1fd1b68e5a8c49aa69290b1accb7f 100644 (file)
@@ -141,7 +141,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
             topPosition += tb.getOffsetHeight();
             setPopupPosition(x, topPosition);
 
-            final int first = currentPage * PAGELENTH
+            final int first = currentPage * pageLength
                     + (nullSelectionAllowed && currentPage > 0 ? 0 : 1);
             final int last = first + currentSuggestions.size() - 1;
             final int matches = totalSuggestions
@@ -158,7 +158,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
             }
             // We don't need to show arrows or statusbar if there is only one
             // page
-            if (matches <= PAGELENTH) {
+            if (matches <= pageLength) {
                 setPagingEnabled(false);
             } else {
                 setPagingEnabled(true);
@@ -290,7 +290,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
             menu.setHeight("");
             if (currentPage > 0) {
                 // fix height to avoid height change when getting to last page
-                menu.fixHeightTo(PAGELENTH);
+                menu.fixHeightTo(pageLength);
             }
             offsetHeight = getOffsetHeight();
 
@@ -501,7 +501,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
 
     private static final String CLASSNAME = "v-filterselect";
 
-    public static final int PAGELENTH = 10;
+    protected int pageLength = 10;
 
     private final FlowPanel panel = new FlowPanel();
 
@@ -591,7 +591,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
     }
 
     public boolean hasNextPage() {
-        if (totalMatches > (currentPage + 1) * PAGELENTH) {
+        if (totalMatches > (currentPage + 1) * pageLength) {
             return true;
         } else {
             return false;
@@ -657,6 +657,10 @@ public class VFilterSelect extends Composite implements Paintable, Field,
 
         currentPage = uidl.getIntVariable("page");
 
+        if (uidl.hasAttribute("pagelength")) {
+            pageLength = uidl.getIntAttribute("pagelength");
+        }
+
         if (uidl.hasAttribute(ATTR_INPUTPROMPT)) {
             // input prompt changed from server
             inputPrompt = uidl.getStringAttribute(ATTR_INPUTPROMPT);
@@ -716,7 +720,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
                 // we're paging w/ arrows
                 if (lastIndex == 0) {
                     // going up, select last item
-                    int lastItem = PAGELENTH - 1;
+                    int lastItem = pageLength - 1;
                     List items = suggestionPopup.menu.getItems();
                     /*
                      * The first page can contain less than 10 items if the null
index 9b16830a313aa870e8a5ceb96f6a3fd2c9717aac..6d07aff5b39629fd7f991a093719760ca64b21ce 100644 (file)
@@ -137,6 +137,8 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering {
                     && getNullSelectionItemId() == null ? 0 : 1)];
         }
 
+        target.addAttribute("pagelength", pageLength);
+
         target.addAttribute("filteringmode", getFilteringMode());
 
         // Paints the options and create array of selected id keys