1 package org.jahia.taglibs.button; 2 3 import java.util.Enumeration ; 4 5 import javax.servlet.jsp.JspException ; 6 7 import org.jahia.data.JahiaData; 8 import org.jahia.data.containers.JahiaContainerList; 9 import org.jahia.exceptions.JahiaException; 10 import org.jahia.services.usermanager.JahiaUser; 11 import org.jahia.taglibs.container.ContainerListTag; 12 13 21 23 public class PreviousWindowButtonTag extends AbstractButtonTag { 24 25 private JahiaContainerList containerList = null; 26 private String title = "<<Previous"; 27 private String style = ""; 28 private String method = "get"; 29 private String formName = ""; 30 31 private int windowStepInt = 1; 32 private int windowSizeInt = -1; 33 34 private String windowStep; 36 private String windowSize; 37 38 public void setTitle(String title) { 39 this.title = title; 40 } 41 42 public void setStyle(String style) { 43 this.style = style; 44 } 45 46 public void setMethod(String method) { 47 if ( method != null ) 48 { 49 this.method = method; 50 } 51 } 52 53 public void setFormName(String formName) { 54 if ( formName != null ) 55 { 56 this.formName = formName.trim(); 57 } 58 } 59 60 public void setWindowStep(String windowStep) { 61 this.windowStep = windowStep; 62 try { 63 windowStepInt = Integer.parseInt(windowStep); 64 if (windowStepInt < 0) 65 windowStepInt = 0; 66 } catch (NumberFormatException nfe) { 67 windowStepInt = 0; 68 } 69 } 70 71 public void setWindowSize(String windowSize) { 72 this.windowSize = windowSize; 73 try { 74 windowSizeInt = Integer.parseInt(windowSize); 75 if (windowSizeInt < 1) 76 windowSizeInt = -1; 77 } catch (NumberFormatException nfe) { 78 windowSizeInt = -1; 79 } 80 } 81 82 public String getTitle() { 83 return this.title; 84 } 85 86 public String getStyle() { 87 return this.style; 88 } 89 90 public String getMethod() { 91 return this.method; 92 } 93 94 public String getFormName() { 95 return this.formName; 96 } 97 98 public int getWindowStepInt() { 99 return this.windowStepInt; 100 } 101 102 public int getWindowSizeInt() { 103 return this.windowSizeInt; 104 } 105 106 public String getWindowStep() { 107 return this.windowStep; 108 } 109 110 public String getWindowSize() { 111 return this.windowSize; 112 } 113 114 public boolean testRights (JahiaData jData) { 115 JahiaUser user = jData.params().getUser(); 116 ContainerListTag parent = (ContainerListTag) findAncestorWithClass(this,ContainerListTag.class); 118 if (parent != null) { 119 containerList = parent.getContainerList(); 120 } 121 if (containerList != null) { 122 Enumeration containers = containerList.getContainers(); 123 return ( containers.hasMoreElements() ); 124 } 125 return false; 126 } 127 128 public String getLauncher(JahiaData jData) throws JahiaException { 129 String value = jData.gui().drawContainerListPreviousWindowPageURL( containerList, windowStepInt, windowSizeInt, this.method.equals("post") ); 130 if ( value != null && this.method.equals("post") ) 131 { 132 StringBuffer buff = new StringBuffer ("javascript:changePage(document."); 133 buff.append(getFormName()); 134 buff.append(",document."); 135 buff.append(getFormName()); 136 buff.append(".ctnscroll_"); 137 buff.append(containerList.getDefinition().getName()); 138 buff.append(",'"); 139 buff.append(value); 140 buff.append("');"); 141 value = buff.toString(); 142 } 143 144 return value; 145 } 146 147 public int doEndTag() throws JspException { 148 containerList = null; 151 title = "<<Previous"; 152 style = ""; 153 method = "get"; 154 formName = ""; 155 156 windowStepInt = 1; 157 windowSizeInt = -1; 158 159 windowStep = null; 160 windowSize = null; 161 return EVAL_PAGE; 162 } 163 164 165 } | Popular Tags |