Adobe COLDFUSION 9 Manual page 1150

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
<!--- Get reference to home object. --->
<cfset home = initContext.lookup("SimpleBean")>
<!--- Create new instance of entity bean.
(hard-wired account number). Alternatively,
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
on page 1137. 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,
. Its constructor initializes
mPublicInt
methods:
Method
ReverseString
ReverseStringArray
Add
SumArray
SumObjArray
ReverseArray
Flip
to 0 or an integer argument. The class has the following public
mPublicInt
Description
Reverses the order of a string.
Reverses the order of elements in an array of strings.
Overloaded: Adds and returns two integers or floats or adds the
Example class objects and returns an Example class object.
Returns the sum of the elements in an integer array.
Adds the values of the
mPublicInt
Example class object.
Reverses the order of an array of integers.
Switches a Boolean value.
Last updated 8/5/2010
"Creating and using a simple Java
mPublicInt
members of an array of Example class objects and returns an
1145
class"
members of two

Advertisement

Table of Contents
loading

Table of Contents