1 28 29 import net.sf.jasperreports.engine.JRDefaultScriptlet; 30 import net.sf.jasperreports.engine.JRScriptletException; 31 32 33 37 public class Scriptlet extends JRDefaultScriptlet 38 { 39 40 41 44 public void beforeReportInit() throws JRScriptletException 45 { 46 System.out.println("call beforeReportInit"); 47 } 48 49 50 53 public void afterReportInit() throws JRScriptletException 54 { 55 System.out.println("call afterReportInit"); 56 } 57 58 59 62 public void beforePageInit() throws JRScriptletException 63 { 64 System.out.println("call beforePageInit : PAGE_NUMBER = " + this.getVariableValue("PAGE_NUMBER")); 65 } 66 67 68 71 public void afterPageInit() throws JRScriptletException 72 { 73 System.out.println("call afterPageInit : PAGE_NUMBER = " + this.getVariableValue("PAGE_NUMBER")); 74 } 75 76 77 80 public void beforeColumnInit() throws JRScriptletException 81 { 82 System.out.println("call beforeColumnInit"); 83 } 84 85 86 89 public void afterColumnInit() throws JRScriptletException 90 { 91 System.out.println("call afterColumnInit"); 92 } 93 94 95 98 public void beforeGroupInit(String groupName) throws JRScriptletException 99 { 100 if (groupName.equals("CityGroup")) 101 { 102 System.out.println("call beforeGroupInit : City = " + this.getFieldValue("City")); 103 } 104 } 105 106 107 110 public void afterGroupInit(String groupName) throws JRScriptletException 111 { 112 if (groupName.equals("CityGroup")) 113 { 114 System.out.println("call afterGroupInit : City = " + this.getFieldValue("City")); 115 116 String allCities = (String )this.getVariableValue("AllCities"); 117 String city = (String )this.getFieldValue("City"); 118 StringBuffer sbuffer = new StringBuffer (); 119 120 if (allCities != null) 121 { 122 sbuffer.append(allCities); 123 sbuffer.append(", "); 124 } 125 126 sbuffer.append(city); 127 this.setVariableValue("AllCities", sbuffer.toString()); 128 } 129 } 130 131 132 135 public void beforeDetailEval() throws JRScriptletException 136 { 137 System.out.println(" detail"); 138 } 139 140 141 144 public void afterDetailEval() throws JRScriptletException 145 { 146 } 147 148 149 152 public String hello() throws JRScriptletException 153 { 154 return "Hello! I'm the report's scriptlet object."; 155 } 156 157 158 } 159 | Popular Tags |