From 3d9a9cf0671c110f7e29e06e2dd819ad6dbb86d6 Mon Sep 17 00:00:00 2001 From: Eudaldo Alonso Date: Sat, 12 Aug 2023 08:10:53 +0100 Subject: [PATCH] LPS-193394 Avoid using count to get the activePage --- ...tionLayoutStructureItemDisplayContext.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/modules/apps/layout/layout-taglib/src/main/java/com/liferay/layout/taglib/internal/display/context/RenderCollectionLayoutStructureItemDisplayContext.java b/modules/apps/layout/layout-taglib/src/main/java/com/liferay/layout/taglib/internal/display/context/RenderCollectionLayoutStructureItemDisplayContext.java index e6f58d44cdc816..bd4ebd9a84d35a 100644 --- a/modules/apps/layout/layout-taglib/src/main/java/com/liferay/layout/taglib/internal/display/context/RenderCollectionLayoutStructureItemDisplayContext.java +++ b/modules/apps/layout/layout-taglib/src/main/java/com/liferay/layout/taglib/internal/display/context/RenderCollectionLayoutStructureItemDisplayContext.java @@ -92,15 +92,20 @@ public int getActivePage() { return _activePage; } - _activePage = Math.max( - 1, - Math.min( - getNumberOfPages(), - ParamUtil.getInteger( - PortalUtil.getOriginalServletRequest(_httpServletRequest), - PAGE_NUMBER_PARAM_PREFIX + - _collectionStyledLayoutStructureItem.getItemId(), - 1))); + _activePage = ParamUtil.getInteger( + PortalUtil.getOriginalServletRequest(_httpServletRequest), + PAGE_NUMBER_PARAM_PREFIX + + _collectionStyledLayoutStructureItem.getItemId(), + 1); + + int numberOfPages = + _collectionStyledLayoutStructureItem.getNumberOfPages(); + + if (!_collectionStyledLayoutStructureItem.isDisplayAllPages() && + (_activePage > numberOfPages)) { + + _activePage = numberOfPages - 1; + } return _activePage; }