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 19 20 public class CListPaginationPageUrlTag extends AbstractButtonTag { 21 22 private JahiaContainerList containerList = null; 23 private JahiaContainerListPagination cPagination = null; 24 private CListPaginationTag cPaginationTag = null; 25 26 private String title = ""; 27 private String style = ""; 28 private String method = "get"; 29 private String formName = ""; 30 31 public void setTitle(String title) { 32 this.title = title; 33 } 34 35 public void setStyle(String style) { 36 this.style = style; 37 } 38 39 public void setMethod(String method) { 40 if ( method != null ) 41 { 42 this.method = method; 43 } 44 } 45 46 public void setFormName(String formName) { 47 if ( formName != null ) 48 { 49 this.formName = formName.trim(); 50 } 51 } 52 53 public String getTitle() { 54 return this.title; 55 } 56 57 public String getStyle() { 58 return this.style; 59 } 60 61 public String getMethod() { 62 return this.method; 63 } 64 65 public String getFormName() { 66 return this.formName; 67 } 68 69 public boolean testRights (JahiaData jData) { 70 cPaginationTag = (CListPaginationTag) findAncestorWithClass(this,CListPaginationTag.class); 71 if ( cPaginationTag == null ){ 72 return false; 73 } 74 ContainerListTag parent = (ContainerListTag) findAncestorWithClass(this,ContainerListTag.class); 75 if (parent != null) { 76 this.containerList = parent.getContainerList(); 77 if ( this.containerList != null ){ 78 this.cPagination = this.containerList.getCtnListPagination(); 79 if ( this.cPagination != null && this.cPagination.isValid()) 80 { 81 return true; 82 } 83 } 84 } 85 return false; 86 } 87 88 public String getLauncher(JahiaData jData) throws JahiaException { 89 this.title = String.valueOf(cPaginationTag.getPageNumber()); 90 91 String value = jData.gui().drawContainerListWindowPageURL( containerList, cPaginationTag.getPageNumber(), this.method.equals("post") ); 92 if ( value != null && this.method.equals("post") ) 93 { 94 StringBuffer buff = new StringBuffer ("javascript:changePage(document."); 95 buff.append(getFormName()); 96 buff.append(",document."); 97 buff.append(getFormName()); 98 buff.append(".ctnscroll_"); 99 buff.append(containerList.getDefinition().getName()); 100 buff.append(",'"); 101 buff.append(value); 102 buff.append("');"); 103 value = buff.toString(); 104 } 105 return value; 106 } 107 108 public int doEndTag() throws JspException { 109 containerList = null; 112 cPagination = null; 113 cPaginationTag = null; 114 115 title = ""; 116 style = ""; 117 method = "get"; 118 formName = ""; 119 return EVAL_PAGE; 120 } 121 122 } | Popular Tags |