User Guide

Table Of Contents
940 Chapter 37: Integrating J2EE and Java Elements in CFML Applications
you would use a find method to locate an existing entity bean. --->
<cfset mySimple = home.create()>
<!--- Call a method in the entity bean. --->
<cfset myMessage = mySimple.getMessage()>
<cfoutput>
#myMessage#<br>
</cfoutput>
<!--- Close the context. --->
<cfset initContext.close()>
</body>
</html>
Using a custom Java class
The following code provides a more complex custom class than in the example “Creating and
using a simple Java class” on page 930. The Example class manipulates integer, float, array,
Boolean, and Example object types.
The Example class
The following Java code defines the Example class. The Java class Example has one public integer
member,
mPublicInt. Its constructor initializes mPublicInt to 0 or an integer argument. The
class has the following public methods:
public class Example {
public int mPublicInt;
public Example() {
mPublicInt = 0;
}
public Example(int IntVal) {
mPublicInt = IntVal;
}
Method Description
ReverseString Reverses the order of a string.
ReverseStringArray Reverses the order of elements in an array of strings.
Add Overloaded: Adds and returns two integers or floats or adds the
mPublicInt members of two Example class objects and returns an
Example class object.
SumArray Returns the sum of the elements in an integer array.
SumObjArray Adds the values of the
mPublicInt members of an array of Example
class objects and returns an Example class object.
ReverseArray Reverses the order of an array of integers.
Flip Switches a Boolean value.