format(row["ORDERDATE"]);
In this example, we are using the Java SimpleDateFormat object to format our date
object instead of the straight JavaScript method we used in the Gauge Chart example.
The reason this is possible is that any object that is available in the Classpath for the
BIRT Runtime Environment is available for use in your reports. So by default, any
of the intrinsic Java objects are usable, such as the SimpleDateFormat object. The
caveat is that you need to import the object using the importPackage() method.
Looking at the first line of code above, we are including the java.text package,
of which the SimpleDataFormat object is a part. This method is part of the Mozilla
Rhino JavaScript Engine, which BIRT uses for its Script processing. In the next line,
we are creating a dataFormater variable and assigning it a new implementation of
the SimpleDateFormat object, and assigning the format the default of YYYY-MM.
The third line returns the formatted result as a String because the SimpleDataFormat
method returns a String. Keep in mind when building Expressions that you can use
any Java object in your report that is available in the Java Classpath.
Event Handling
So, if Expressions are simple lines of code that return a single value, how do Event
Handlers fit into the Scripting world in BIRT? Simple! They do exactly what they say
they do; they handle events.
Pages:
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193