1 package org.jahia.taglibs.pagination; 2 3 import javax.servlet.jsp.JspException ; 4 5 import org.jahia.data.JahiaData; 6 import org.jahia.data.containers.JahiaContainerList; 7 import org.jahia.data.containers.JahiaContainerListPagination; 8 import org.jahia.exceptions.JahiaException; 9 import org.jahia.taglibs.button.AbstractButtonTag; 10 import org.jahia.taglibs.container.ContainerListTag; 11 12 20 21 public class CListPaginationNextRangeOfPagesTag extends AbstractButtonTag { 22 23 private JahiaContainerList containerList = null; 24 private JahiaContainerListPagination cPagination = null; 25 private CListPaginationTag cPaginationTag = null; 26 27 private String title = "Next>>"; 28 private String style = ""; 29 private String method = "get"; 30 private String formName = ""; 31 private boolean evaluateOnce = false; 32 33 public void setTitle(String title) { 34 this.title = title; 35 } 36 37 public void setStyle(String style) { 38 this.style = style; 39 } 40 41 public void setMethod(String method) { 42 if ( method != null ) 43 { 44 this.method = method; 45 } 46 } 47 48 public void setFormName(String formName) { 49 if ( formName != null ) 50 { 51 this.formName = formName.trim(); 52 } 53 } 54 55 public String getTitle() { 56 return this.title; 57 } 58 59 public String getStyle() { 60 return this.style; 61 } 62 63 public String getMethod() { 64 return this.method; 65 } 66 67 public String getFormName() { 68 return this.formName; 69 } 70 71 public boolean testRights (JahiaData jData) { 72 73 cPaginationTag = (CListPaginationTag) findAncestorWithClass(this,CListPaginationTag.class); 74 if ( cPaginationTag == null ){ 75 return false; 76 } 77 if ( cPaginationTag.getNbStepPerPage()<=0 ){ 78 return false; 79 } 80 ContainerListTag parent = (ContainerListTag) findAncestorWithClass(this,ContainerListTag.class); 81 if (parent != null) { 82 this.containerList = parent.getContainerList(); 83 if ( this.containerList != null ){ 84 this.cPagination = this.containerList.getCtnListPagination(); 85 if ( this.cPagination != null && this.cPagination.isValid()) 86 { 87 return true; 88 } 89 } 90 } 91 return false; 92 } 93 94 public String getLauncher(JahiaData jData) throws JahiaException { 95 96 String value = null; 97 102 if ( (cPaginationTag.getPageNumber()==(cPaginationTag.getStopPageIndex()) ) 103 && (cPaginationTag.getStopPageIndex()<this.cPagination.getNbPages()) ){ 104 105 107 if ( cPaginationTag.getStartPageIndex()>1 ){ 108 value = jData.gui().drawContainerListNextWindowPageURL( containerList, cPaginationTag.getStopPageIndex()+1-cPagination.getCurrentPageIndex(), this.cPagination.getWindowSize(), this.method.equals("post") ); 109 } else { 110 value = jData.gui().drawContainerListNextWindowPageURL( containerList, cPaginationTag.getNbStepPerPage()+1-cPagination.getCurrentPageIndex(), this.cPagination.getWindowSize(), this.method.equals("post") ); 111 } 112 113 115 if ( value != null && this.method.equals("post") ) 116 { 117 StringBuffer buff = new StringBuffer ("javascript:changePage(document."); 118 buff.append(getFormName()); 119 buff.append(",document."); 120 buff.append(getFormName()); 121 buff.append(".ctnscroll_"); 122 buff.append(containerList.getDefinition().getName()); 123 buff.append(",'"); 124 buff.append(value); 125 buff.append("');"); 126 value = buff.toString(); 127 } 128 } 129 return value; 130 } 131 132 public int doEndTag() throws JspException { 133 containerList = null; 136 cPagination = null; 137 cPaginationTag = null; 138 139 title = "Next>>"; 140 style = ""; 141 method = "get"; 142 formName = ""; 143 evaluateOnce = false; 144 return EVAL_PAGE; 145 } 146 147 } | Popular Tags |