Objects and interfaces for creating UDOs
Example 1: Accessing a record for a UDO and registering the UDO with the report system
The following objects and interfaces are necessary for creating a UDO. Refer to the corresponding class or interface in the JReport Javadoc located at <install_root>\help\api
.
Note: Only JReport system properties or properties inherited from them can be added, such as JetNumber, JetColor, JetString, and JetEnumeration. See the jet.controls package.
Then to create a UDO manually with the objects and interfaces, follow the steps:
<install_root>\lib
by adding the following:
|
<install_root>\bin
.
Note: If you want to use class files for the UDO which have been used in previous versions, you should re-compile the source files.
This example describes how to access a record for your UDO and how to register your UDO with the report system.
|
|
|
|
Note: Since the compiling process of JReport Designer differs with that of JReport Server, when you run UDOs in these two applications, you should pay attention to some minor differences. For example, to get width and height, in JReport Designer, you should use:
w = guitools.toolkit.Unit.convertUnitToPixel(((Integer)propertySetable.getPropertyByName
("Width").getObject()).intValue());
h = guitools.toolkit.Unit.convertUnitToPixel(((Integer)propertySetable.getPropertyByName
("Height").getObject()).intValue());
While in JReport Server, you should use the following instead:
JRObjectResult obj = (JRObjectResult)propertySetable;
w = guitools.toolkit.Unit.convertUnitToPixel(obj.getTemplate().getWidth(obj));
h = guitools.toolkit.Unit.convertUnitToPixel(obj.getTemplate().getHeight(obj));
To compile these four Java files, you should add report.jar and JREngine.jar with their path into the class path (make sure that the path of the file JREngine.jar is before that of the file report.jar). For example, use the following command:
Javac -classpath "C:\JReport\Designer\lib\JRengine.jar;C:\JReport\Designer\lib\report.jar;C:\test "MyDbFld.java
Here it is assumed that JReport Designer is installed to C:\JReport\Designer
. The Java files for the example are in C:\test\myudo
.
<install_root>\lib
directory by appending the four classes as follows:
|
<install_root>\bin
by appending the path of the four classes to the batch file's ADDCLASSPATH variable. Assume that the four classes are located in D:\test\myudo
.
set ADDCLASSPATH=%JAVAHOME%\lib\tools.jar;D:\test;
This example describes how to make a group based on a UDO. This sample is similar to a summary field. This example includes the implementation of four classes and shares a class with Example 1.
|
|
|
<install_root>\lib\
by appending the four classes as follows:
|
<install_root>\bin
by appending the path of the four classes to the batch file's ADDCLASSPATH variable. Assume that the four classes are located in D:\test\myudo
.
set ADDCLASSPATH=%JAVAHOME%\lib\tools.jar;D:\test;