1 package org.jahia.deprecated.taglibs.button; 2 3 import javax.servlet.http.HttpServletRequest ; 4 5 import org.jahia.data.JahiaData; 6 import org.jahia.deprecated.taglibs.util.Utils; 7 import org.jahia.exceptions.JahiaException; 8 import org.jahia.utils.JahiaConsole; 9 10 11 16 public abstract class AbstractRolloverTag extends AbstractButtonTag { 17 18 19 private Integer counter; 21 22 private String className; 24 25 public void checkCounter(HttpServletRequest request) { 28 29 this.className = Utils.getShortClassName(this.getClass()); 31 String counterName = this.className + "_counter"; 33 this.counter = (Integer )request.getAttribute(counterName); 34 if (this.counter == null) { 35 this.counter = new Integer (1); 36 } else { 37 this.counter = new Integer (this.counter.intValue() + 1); 38 } 39 request.setAttribute(counterName, this.counter); 40 } 41 42 43 public String buildButton (JahiaData jData, HttpServletRequest request) { 45 46 String imgDir = getImgDir(); 48 String width = getWidth(); 49 String height = getHeight(); 50 String align = getAlign(); 51 String imgName = this.className + "Img_"; 52 String context = jData.gui().drawHttpJspContext(request); 53 String outImage = null; 54 String overImage = null; 55 String launcher = null; 56 try { 57 outImage = getMouseOutImage(jData); 58 overImage = getMouseOverImage(jData); 59 launcher = getLauncher(jData); 60 } catch (JahiaException jex) { 61 JahiaConsole.println("AbstractRolloverTag: buildButton ", "Can not get launcher from subclass !"); 62 return null; 63 } 64 StringBuffer text = new StringBuffer ( "<a HREF=\"" ); 65 text.append( launcher ); 66 text.append( "\" onMouseOut=\"document." ); 67 text.append( imgName ); 68 text.append( this.counter ); 69 text.append( ".src='" ); 70 text.append( context ); 71 text.append( "/" ); 72 text.append( imgDir ); 73 text.append( "/" ); 74 text.append( outImage ); 75 text.append( "';\" onMouseOver=\"document." ); 76 text.append( imgName ); 77 text.append( this.counter ); 78 text.append( ".src='" ); 79 text.append( context ); 80 text.append( "/" ); 81 text.append( imgDir ); 82 text.append( "/" ); 83 text.append( overImage ); 84 text.append( "';\"><img name=\"" ); 85 text.append( imgName ); 86 text.append( this.counter.intValue() ); 87 text.append( "\" SRC=\"" ); 88 text.append( context ); 89 text.append( "/" ); 90 text.append( imgDir ); 91 text.append( "/" ); 92 text.append( outImage ); 93 text.append( "\"" ); 94 if ( !width.equals("" ) ) { 95 text.append( " width=\"" ); 96 text.append( width ); 97 text.append( "\"" ); 98 } 99 if ( !height.equals("") ) { 100 text.append( " height=\"" ); 101 text.append( height ); 102 text.append( "\"" ); 103 } 104 if ( !align.equals("") ) { 105 text.append( " align=\"" ); 106 text.append( align ); 107 text.append( "\"" ); 108 } 109 110 text.append( " border=\"0\" alt=\"\">" ); 111 text.append( getTitle() ); 112 text.append( "</a>" ); 113 return text.toString(); 114 } 115 116 public String getTitle() { 117 return ""; 118 } 119 120 public String getStyle() { 121 return ""; 122 } 123 124 public String getAlign(){ 125 return ""; 126 }; 127 128 public abstract String getMouseOverImage(JahiaData jData) throws JahiaException; 130 131 public abstract String getMouseOutImage(JahiaData jData) throws JahiaException; 132 133 public abstract String getImgDir(); 134 135 public abstract String getWidth(); 136 137 public abstract String getHeight(); 138 public String getClassName() { 139 return className; 140 } 141 public Integer getCounter() { 142 return counter; 143 } 144 145 } 146 147 148 | Popular Tags |