You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2018/03/01 03:53:58 UTC

[sling-whiteboard] branch master updated: Separated out the configuration to make it easier to create non-configurable lists

This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new a5a1342  Separated out the configuration to make it easier to create non-configurable lists
a5a1342 is described below

commit a5a1342007f250807ab5929134c5acf08a1c9009
Author: Dan Klco <da...@gmail.com>
AuthorDate: Wed Feb 28 19:53:54 2018 -0800

    Separated out the configuration to make it easier to create
    non-configurable lists
---
 .../apache/sling/cms/reference/models/ItemList.java  | 10 +++++-----
 .../components/general/list/{list.jsp => init.jsp}   | 20 +++++++-------------
 .../apps/reference/components/general/list/list.jsp  | 10 +++-------
 3 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/cms/core/src/main/java/org/apache/sling/cms/reference/models/ItemList.java b/cms/core/src/main/java/org/apache/sling/cms/reference/models/ItemList.java
index c0375b7..231e298 100644
--- a/cms/core/src/main/java/org/apache/sling/cms/reference/models/ItemList.java
+++ b/cms/core/src/main/java/org/apache/sling/cms/reference/models/ItemList.java
@@ -24,11 +24,10 @@ import javax.annotation.PostConstruct;
 import javax.jcr.query.Query;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.jackrabbit.util.Text;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.models.annotations.Model;
-import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
+import org.apache.sling.models.annotations.injectorspecific.RequestAttribute;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,14 +44,14 @@ public class ItemList {
 
 	private int end;
 
-	@ValueMapValue
-	private int limit;
+	@RequestAttribute
+	private String limit;
 
 	private int page;
 
 	private Integer[] pages;
 
-	@ValueMapValue
+	@RequestAttribute
 	private String query;
 
 	private SlingHttpServletRequest request;
@@ -124,6 +123,7 @@ public class ItemList {
 			log.debug("Page {} not specified or not valid", request.getParameter("page"));
 		}
 
+		int limit = Integer.parseInt(this.limit, 10);
 		if (page * limit >= count) {
 			start = count;
 		} else {
diff --git a/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/list/list.jsp b/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/list/init.jsp
similarity index 71%
copy from cms/ui/src/main/resources/jcr_root/apps/reference/components/general/list/list.jsp
copy to cms/ui/src/main/resources/jcr_root/apps/reference/components/general/list/init.jsp
index f92b450..0ca29e2 100644
--- a/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/list/list.jsp
+++ b/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/list/init.jsp
@@ -17,19 +17,13 @@
  * under the License.
  */ --%>
  <%@include file="/libs/sling-cms/global.jsp"%>
-<sling:adaptTo var="pageMgr" adaptable="${resource}" adaptTo="org.apache.sling.cms.core.models.PageManager" />
+ <sling:adaptTo adaptable="${resource}" adaptTo="org.apache.sling.cms.core.models.PageManager" var="pageMgr" />
+<c:set var="query" value="${properties.query}" scope="request" />
+<c:set var="limit" value="${properties.limit}" scope="request" />
+<c:set var="includePagination" value="${properties.includePagination}" scope="request" />
+<c:set var="tag" value="${not empty properties.tag ? properties.tag : 'ul'}" scope="request" />
+<c:set var="clazz" value="${not empty properties.class ? properties.class : ''}" scope="request" />
 <c:set var="listConfig" value="${pageMgr.page.template.componentConfigs['reference/components/general/list']}" scope="request" />
-<c:set var="tag" value="${not empty properties.tag ? properties.tag : 'ul'}" />
-<c:set var="clazz" value="${not empty properties.class ? properties.class : ''}" />
-<c:if test="${not empty properties.limit}">
+<c:if test="${not empty query}">
 	<c:set var="list" value="${sling:adaptTo(slingRequest, 'org.apache.sling.cms.reference.models.ItemList')}" scope="request"  />
-	<${tag} class="list ${clazz}">
-		<c:forEach var="it" items="${list.items}">
-			<c:set var="item" value="${it}" scope="request" />
-			<sling:call script="item.jsp" />
-		</c:forEach>
-		<c:if test="${properties.includePagination}">
-			<sling:call script="pagination.jsp" />
-		</c:if>
-	</${tag}>
 </c:if>
\ No newline at end of file
diff --git a/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/list/list.jsp b/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/list/list.jsp
index f92b450..3c165e2 100644
--- a/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/list/list.jsp
+++ b/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/list/list.jsp
@@ -17,18 +17,14 @@
  * under the License.
  */ --%>
  <%@include file="/libs/sling-cms/global.jsp"%>
-<sling:adaptTo var="pageMgr" adaptable="${resource}" adaptTo="org.apache.sling.cms.core.models.PageManager" />
-<c:set var="listConfig" value="${pageMgr.page.template.componentConfigs['reference/components/general/list']}" scope="request" />
-<c:set var="tag" value="${not empty properties.tag ? properties.tag : 'ul'}" />
-<c:set var="clazz" value="${not empty properties.class ? properties.class : ''}" />
-<c:if test="${not empty properties.limit}">
-	<c:set var="list" value="${sling:adaptTo(slingRequest, 'org.apache.sling.cms.reference.models.ItemList')}" scope="request"  />
+<sling:call script="init.jsp" />
+<c:if test="${list != null}">
 	<${tag} class="list ${clazz}">
 		<c:forEach var="it" items="${list.items}">
 			<c:set var="item" value="${it}" scope="request" />
 			<sling:call script="item.jsp" />
 		</c:forEach>
-		<c:if test="${properties.includePagination}">
+		<c:if test="${includePagination}">
 			<sling:call script="pagination.jsp" />
 		</c:if>
 	</${tag}>

-- 
To stop receiving notification emails like this one, please contact
dklco@apache.org.