You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2015/03/30 16:52:39 UTC

tapestry-5 git commit: TAP5-2437: NullPointerException when trying to access (read or write) Grid's currentPage

Repository: tapestry-5
Updated Branches:
  refs/heads/master 133471ebf -> d64dfa1d1


TAP5-2437: NullPointerException when trying to access (read or write) Grid's currentPage


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/d64dfa1d
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/d64dfa1d
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/d64dfa1d

Branch: refs/heads/master
Commit: d64dfa1d1be046889946729bc787a536f66feb70
Parents: 133471e
Author: Felix Scheffer <ma...@felix-scheffer.de>
Authored: Fri Mar 20 18:53:40 2015 +0100
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Mon Mar 30 16:42:27 2015 +0200

----------------------------------------------------------------------
 .../tapestry5/corelib/components/Grid.java      | 15 +++----
 .../src/test/app1/GridEarlyPagingDemo.tml       | 10 +++++
 .../tapestry5/integration/app1/GridTests.java   | 12 ++++++
 .../app1/pages/GridEarlyPagingDemo.java         | 44 ++++++++++++++++++++
 .../tapestry5/integration/app1/pages/Index.java |  2 +
 5 files changed, 73 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d64dfa1d/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java
index bc4dae2..110b9a1 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Grid.java
@@ -224,7 +224,6 @@ public class Grid implements GridModel, ClientElement
     @Parameter(value = "defaultPaginationModel")
     private GridPaginationModel paginationModel;
 
-    @Property
     @Persist
     private GridPaginationModel defaultPaginationModel;
 
@@ -352,8 +351,6 @@ public class Grid implements GridModel, ClientElement
         {
             assert InternalUtils.isNonBlank(columnId);
 
-            setupPaginationModel();
-
             if (columnId.equals(paginationModel.getSortColumnId()))
             {
                 setSortAscending(!getSortAscending());
@@ -381,7 +378,6 @@ public class Grid implements GridModel, ClientElement
 
         public void clear()
         {
-            setupPaginationModel();
             paginationModel.setSortColumnId(null);
             paginationModel.setSortAscending(null);
         }
@@ -455,9 +451,6 @@ public class Grid implements GridModel, ClientElement
 
     Object setupRender()
     {
-
-        setupPaginationModel();
-
         if (formSupport != null)
         {
             formSupport.store(this, SETUP_DATA_SOURCE);
@@ -477,12 +470,14 @@ public class Grid implements GridModel, ClientElement
         zone = null;
     }
 
-    private void setupPaginationModel()
+    public GridPaginationModel getDefaultPaginationModel()
     {
-        if (paginationModel == null)
+        if (defaultPaginationModel == null)
         {
-            paginationModel = new GridPaginationModelImpl();
+            defaultPaginationModel = new GridPaginationModelImpl();
         }
+
+        return defaultPaginationModel;
     }
 
     void setupDataSource()

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d64dfa1d/tapestry-core/src/test/app1/GridEarlyPagingDemo.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/GridEarlyPagingDemo.tml b/tapestry-core/src/test/app1/GridEarlyPagingDemo.tml
new file mode 100644
index 0000000..2b2eafd
--- /dev/null
+++ b/tapestry-core/src/test/app1/GridEarlyPagingDemo.tml
@@ -0,0 +1,10 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+    <h1>Grid Demo</h1>
+
+    <table t:type="grid" t:id="grid" source="tracks">
+
+    </table>
+
+
+</html>

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d64dfa1d/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/GridTests.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/GridTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/GridTests.java
index f18f618..73afb6a 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/GridTests.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/GridTests.java
@@ -366,6 +366,18 @@ public class GridTests extends App1TestCase
         assertTextPresent(" Deleted Studying Stones");
 
     }
+    
+    /**
+     * TAP5-2437
+     */
+    @Test
+    public void set_grid_current_page_before_first_render()
+    {
+        openLinks("Grid Early Paging");
+
+        assertTextPresent("Walking On Broken Glass");
+
+    }
 
 
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d64dfa1d/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/GridEarlyPagingDemo.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/GridEarlyPagingDemo.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/GridEarlyPagingDemo.java
new file mode 100644
index 0000000..f8f7c8d
--- /dev/null
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/GridEarlyPagingDemo.java
@@ -0,0 +1,44 @@
+// Copyright 2007, 2008, 2011 The Apache Software Foundation
+//
+// Licensed 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.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.SetupRender;
+import org.apache.tapestry5.corelib.components.Grid;
+import org.apache.tapestry5.integration.app1.data.Track;
+import org.apache.tapestry5.integration.app1.services.MusicLibrary;
+import org.apache.tapestry5.ioc.annotations.Inject;
+
+import java.util.List;
+
+public class GridEarlyPagingDemo
+{
+    @Inject
+    private MusicLibrary library;
+
+    @InjectComponent
+    private Grid grid;
+
+    public List<Track> getTracks()
+    {
+        return library.getTracks();
+    }
+
+    @SetupRender
+    void jumpTo2ndPage(){
+      grid.setCurrentPage(2);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d64dfa1d/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
index 3c75ce7..4d4c4f3 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
@@ -342,6 +342,8 @@ public class Index
                             "handling of remove and reorder parameters"),
 
                     new Item("EmptyGrid", "Empty Grid Demo", "show table for empty data sources"),
+                    
+                    new Item("GridEarlyPagingDemo", "Grid Early Paging", "set a Grid's current page before rendering"),
 
                     new Item("protected", "Protected Page",
                             "Demonstrate result of non-void return from a page's activate method"),