• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Using Java Beans

You can use Java Beans in your ColdFusion pages in the same way that you use ordinary Java classes. For writing ColdFusion code, there isn't much difference between a Bean and a normal class. You still use <cfobject> or CreateObject() to load the class, and then call its methods using <cfset> or other tags, as shown in the examples from the preceding section of this chapter.

The only difference is that any properties of the Bean can be accessed by name. Java Bean properties are the Bean's properly named getter and setter methods to store and retrieve the value of the property. So, if a Bean has a property called modelYear (which means nothing more than that getModelYear() and setModelYear() methods have been implemented within the Bean itself), then you could output the value of the property like so:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint