MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 747

Developing coldfusion mx applications
Table of Contents

Advertisement

Using properties
Use the following coding syntax to access properties if the object does either of the following
actions:
Exposes the properties as public properties.
Does not make the properties public, but is a JavaBean that provides public getter and setter
methods of the form getPropertyName() and setPropertyName(value). For more information,
see the following
"Calling JavaBean get and set methods"
To set a property:
<cfset obj.property = "somevalue">
To get a property:
<cfset value = obj.property>
Note: ColdFusion does not require that property and method names be consistently capitalized.
However, you should use the same case in ColdFusion as you do in Java to ensure consistency.
Calling methods
Object methods usually take zero or more arguments. Some methods return values, while others
might not. Use the following techniques to call methods:
If the method has no arguments, follow the method name with empty parentheses, as in the
following
tag:
cfset
<cfset retVal = obj.Method1()>
If the method has one or more arguments, put the arguments in parentheses, separated by
commas, as in the following example, which has one integer argument and one string
argument:
<cfset x = 23>
<cfset retVal = obj.Method1(x, "a string literal")>
Note: When you invoke a Java method, the type of the data being used is important. For more
information see
"Java and ColdFusion data type conversions" on page
Calling JavaBean get and set methods
ColdFusion can automatically invoke getPropertyName() and setPropertyName(value) methods if a
Java class conforms to the JavaBeans pattern. As a result, you can set or get the property by
referencing it directly, without having to explicitly invoke a method.
For example, if the myFishTank class is a JavaBean, the following code returns the results of
calling the getTotalFish() method on the myFish object:
<cfoutput>
There are currently #myFish.TotalFish# fish in the tank.
</cfoutput>
The following example adds one guppy to a myFish object by implicitly calling the
setGuppyCount(int number) method:
<cfset myFish.GuppyCount = myFish.GuppyCount + 1>
section.
751.
Using Java objects
747

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Coldfusion mx

Table of Contents