Permalink
Browse files

Added info about exception thrown in PaginatorComponent

  • Loading branch information...
1 parent 85258f8 commit 70de2d7e03073a06a87b0928a6c6838dee95abe0 @ADmad ADmad committed Dec 28, 2012
Showing with 21 additions and 0 deletions.
  1. +3 −0 en/appendices/2-3-migration-guide.rst
  2. +18 −0 en/core-libraries/components/pagination.rst
@@ -39,6 +39,9 @@ PaginatorComponent
specify what find method you want used for pagination. This is a bit easier
to manage and set than the 0'th index.
+- PaginatorComponent now throws a `NotFoundException` when trying to access a page
+ which is out of range (i.e. requested page is greater than total page count).
+
SecurityComponent
-----------------
@@ -206,6 +206,7 @@ the keyword in controller's ``$paginate`` class variable::
'group' => array('week', 'home_team_id', 'away_team_id')
)
);
+ }
In CakePHP 2.0, you no longer need to implement ``paginateCount()`` when using
group clauses. The core ``find('count')`` will correctly count the total number
@@ -294,6 +295,23 @@ arguments.
Either of these approaches will solve the notice errors.
+Out of range page requests
+==========================
+As of 2.3 the PaginatorComponent will throw a `NotFoundException` when trying to
+access a non-existent page, i.e. page number requested is greater than total
+page count.
+
+So you could either let the normal error page be rendered or use a try catch
+block and take appropriate action when a `NotFoundException` is caught.
+
+ public function index() {
+ try {
+ $this->paginate();
+ } catch (NotFoundException $e) {
+ //Do something here like redirecting to first or last page.
+ //$this->request->params['paging'] will give you required info.
+ }
+ }
AJAX Pagination
===============

0 comments on commit 70de2d7

Please sign in to comment.