Paging tag with facelets
cremersstijn Jul 10, 2008 1:31 PMHi Seam folks!
I'm trying to make a paging tag based on this blog
But i have tweaked the code a little. But i don't want to add the code snippet to all my pages, because it is a lot of code.
So i want to make a custom tag, something like:
<my:paging action="#{projectSearch.search}"/>
That action attribute must come to all the commandLinks actions on the in the paging code.
Is this possible?
<c:choose> <c:when test="#{page.simplePaging}"> <div id="paging"> <h:outputText value="Page #{page.pageIndex} of #{page.lastPageIndex} pages " rendered="#{page.lastPageIndex > 1}"/> <c:forEach var="i" begin="1" end="#{page.lastPageIndex}"> <h:commandLink action="#{projectSearchAction.search}"> <h:outputText value="#{i}"/> <f:param name="ps" value='#{ps != null ? ps : 0}'/> <f:param name="pn" value="#{i}" /> </h:commandLink>   </c:forEach> </div> </c:when> <c:otherwise> <div id="paging"> <h:outputText value="Page #{page.pageIndex} of #{page.lastPageIndex} pages " rendered="#{page.lastPageIndex > 1}"/> <h:commandLink action="#{projectSearchAction.search}" rendered="#{page.pageIndex != 1}"> <h:outputText value="First"/> <f:param name="ps" value='#{ps != null ? ps : 0}'/> <f:param name="pn" value="1" /> </h:commandLink>   <h:outputText value=" 1 " rendered="#{page.pageIndex == 1}"/> <h:commandLink action="#{projectSearchAction.search}" rendered="#{page.pageIndex != 1}"> <h:outputText value="Previous"/> <f:param name="ps" value='#{ps != null ? ps : 0}'/> <f:param name="pn" value="#{page.pageIndex - 1}" /> </h:commandLink>   <h:outputText value=" ... " rendered="#{page.leftDots}"/> <c:forEach var="i" begin="#{page.pageIndex - page.leftSteps}" end="#{page.pageIndex - 1}"> <h:commandLink action="#{projectSearchAction.search}"> <h:outputText value="#{i}"/> <f:param name="ps" value='#{ps != null ? ps : 0}'/> <f:param name="pn" value="#{i}" /> </h:commandLink>   </c:forEach> <h:outputText value=" #{page.pageIndex} " rendered="#{page.showPageIndex()}"/> <c:forEach var="i" begin="#{page.pageIndex + 1}" end="#{page.pageIndex + page.rightSteps}"> <h:commandLink action="#{projectSearchAction.search}"> <f:param name="ps" value='#{ps != null ? ps : 0}'/> <f:param name="pn" value="#{i}" /> </h:commandLink>   </c:forEach> <h:outputText value=" ... " rendered="#{page.rightDots}"/> <h:commandLink action="#{projectSearchAction.search}" rendered="#{page.pageIndex != page.lastPageIndex}"> <h:outputText value="Next"/> <f:param name="ps" value='#{ps != null ? ps : 0}'/> <f:param name="pn" value="#{page.pageIndex + 1}" /> </h:commandLink>   <h:commandLink action="#{projectSearchAction.search}" rendered="#{page.pageIndex != page.lastPageIndex}"> <h:outputText value="Last"/> <f:param name="ps" value='#{ps != null ? ps : 0}'/> <f:param name="pn" value="#{page.lastPageIndex}" /> </h:commandLink>   <h:outputText value=" #{page.lastPageIndex}" rendered="#{page.pageIndex == page.lastPageIndex}"/> </div> </c:otherwise> </c:choose>