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 CListPaginationPreviousRangeOfPagesTag 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 32 public void setTitle(String title) { 33 this.title = title; 34 } 35 36 public void setStyle(String style) { 37 this.style = style; 38 } 39 40 public void setMethod(String method) { 41 if ( method != null ) 42 { 43 this.method = method; 44 } 45 } 46 47 public void setFormName(String formName) { 48 if ( formName != null ) 49 { 50 this.formName = formName.trim(); 51 } 52 } 53 54 public String getTitle() { 55 return this.title; 56 } 57 58 public String getStyle() { 59 return this.style; 60 } 61 62 public String getMethod() { 63 return this.method; 64 } 65 66 public String getFormName() { 67 return this.formName; 68 } 69 70 public boolean testRights (JahiaData jData) { 71 72 cPaginationTag = (CListPaginationTag) findAncestorWithClass(this,CListPaginationTag.class); 73 if ( cPaginationTag == null ){ 74 return false; 75 } 76 if ( cPaginationTag.getNbStepPerPage()<=0 ){ 77 return false; 78 } 79 ContainerListTag parent = (ContainerListTag) findAncestorWithClass(this,ContainerListTag.class); 80 if (parent != null) { 81 this.containerList = parent.getContainerList(); 82 if ( this.containerList != null ){ 83 this.cPagination = this.containerList.getCtnListPagination(); 84 if ( this.cPagination != null && this.cPagination.isValid()) 85 { 86 return true; 87 } 88 } 89 } 90 return false; 91 } 92 93 public String getLauncher(JahiaData jData) throws JahiaException { 94 95 String value = null; 96 101 if ( (cPaginationTag.getPageNumber()==cPaginationTag.getStartPageIndex()) 102 && (cPaginationTag.getStartPageIndex()>1) ){ 103 104 106 value = jData.gui().drawContainerListPreviousWindowPageURL( containerList, cPagination.getCurrentPageIndex()-cPaginationTag.getStartPageIndex()+1, this.cPagination.getWindowSize(), this.method.equals("post") ); 107 109 if ( value != null && this.method.equals("post") ) 110 { 111 StringBuffer buff = new StringBuffer ("javascript:changePage(document."); 112 buff.append(getFormName()); 113 buff.append(",document."); 114 buff.append(getFormName()); 115 buff.append(".ctnscroll_"); 116 buff.append(containerList.getDefinition().getName()); 117 buff.append(",'"); 118 buff.append(value); 119 buff.append("');"); 120 value = buff.toString(); 121 } 122 } 123 return value; 124 } 125 126 public int doEndTag() throws JspException { 127 containerList = null; 130 cPagination = null; 131 cPaginationTag = null; 132 133 title = "Next>>"; 134 style = ""; 135 method = "get"; 136 formName = ""; 137 return EVAL_PAGE; 138 } 139 140 } | Popular Tags |