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