cfcomponent

Creates and defines a component object; encloses functionality that you build in CFML and enclose within cffunction tags. This tag contains one or more cffunction tags that define methods. Code within the body of this tag, other than cffunction tags, is executed when the component is instantiated (like a constructor). Components are saved in a file with a .cfc extension.

 <cfcomponent>

 component displayname="myComponent" output="false" { }

Attribute Reference for the cfcomponent tag

extends

Required: No
Name of parent component from which to inherit methods and properties.

output

Required: No
Specifies whether constructor code in the component can generate HTML output; does not affect output in the body
of cffunction tags in the component.

displayname

Required: No
A string to be displayed when using introspection to show information about the CFC. The information appears on the
heading, following the component name.
If the style attribute is set to document, the displayname
attribute is used as the name of the service element in the WSDL.

hint

Required: No
Text to be displayed when using introspection to show information about the CFC. The hint attribute value
appears below the component name heading. This attribute
can be useful for describing the purpose of the parameter.
If the style attribute is set to document, the hint
attribute is used as the document element of the service
in the WSDL.

style

Required: No
Default: rpc
CF 7+ Specifies whether a CFC used for web services uses RPC-encoded style or document-literal style:
- rpc: RPC-encoded style, default
- document: Document-literal style
If you specify document, you must also specify the namespace,
serviceportname, porttypename, and bindingname attributes. Values:
  • rpc
  • document

namespace

Required: No
CF 7+ Specifies the namespace used in the WSDL when using the CFC as a document-literal style web service.
If you don't specify this attribute, ColdFusion MX
derives the namespace from the CFC class name.
This attribute applies only when style="document".

serviceportname

Required: No
CF 7+ Specifies the name of the port element in the WSDL. This attribute applies only when style="document".

porttypename

Required: No
CF 7+ Specifies the name of the porttype element in the WSDL. This attribute applies only when style="document".

bindingname

Required: No
CF 7+ Specifies the name of the binding element in the WSDL. This attribute applies only when style="document".

wsdlfile

Required: No
CF 7+ A properly formatted WSDL file to be used instead of WSDL generated by ColdFusion MX.
This attribute applies only when style="document".

implements

Required: No
CF 8+ Name of the ColdFusion interface or interfaces that this component implements. If the
component implements an interface, it must
define all the functions in the interface, and the
function definitions must conform to the
definitions specified in the interface. For more
information, see cfinterface.
A component can implement any number of
interfaces. To specify multiple interface, use a
comma delimited list, of the format
interface1,interface2.

serviceaddress

Required: No
CF 8+ Specifies the SOAP URL of the web service.

initmethod

Required: No
CF 9+ Method that will be called when ColdFusion instantiates the component

persistent

Required: No
CF 9+ Specifies CFC is persistent or not

entityname

Required: No
CF 9+ Specifies the name of the entity. Entity name is the name used by the ORM related functions to work with the persistent CFC. If entityname is not specified, then the CFC name is taken as the entityname. The entityname must be unique in the application.

table

Required: No
CF 9+ Specifies the name of the database table to which the CFC maps.

schema

Required: No
CF 9+ Used to specify the schema name.

catalog

Required: No
CF 9+ Used to specify the database catalog name.

dynamicinsert

Required: No
Default: NO
CF 9+ Specifies whether INSERT SQL is to be generated at runtime.
Only those columns whose values are not null are included in the SQL.

dynamicupdate

Required: No
Default: NO
CF 9+ Specifies whether UPDATE SQL is to be generated at runtime.
Only those columns whose values are not null are included in the SQL.

readonly

Required: No
CF 9+ Specify whether table is readonly or not

selectbeforeupdate

Required: No
CF 9+ Specify whether Hibernate should never perform an SQL UPDATE unless it is certain that an object is actually modified.
In cases when a transient object is associated with a new session using update(), Hibernate performs an extra SQL SELECT to determine if an UPDATE is actually required.

batchsize

Required: No
CF 9+ An integer value that specifies the number of records to be retrieved at a single instance.

optimisticlock

Required: No
Default: version
CF 9+ Determines the locking strategy.
It can be any one of the following four values:
none
version
dirty
all Values:
  • none
  • dirty
  • all
  • version

lazy

Required: No
Default: YES
CF 9+ Whether loading is to be done lazily or not.

rowid

Required: No
CF 9+ Row id

discriminatorColumn

Required: No
CF 9+ Use this attribute to define the discriminator column to be used in inheritance mapping

discriminatorValue

Required: No
CF 9+ Use this attribute to define the discriminator value to be used in inheritance mapping

joinColumn

Required: No
CF 9+ Use this attribute to define the join column for inheritance mapping.

embedded

Required: No
CF 9+ Marks CFC as embeded, used when a CFC has an embedded object which also needs to be persisted along with the parent's data

cacheUse

Required: No
CF 9+ Use this value to specify the caching strategy to be used for caching this component's data in the secondary cache Values:
  • read-only
  • nonstrict-read-write
  • read-write
  • transactional

cacheName

Required: No
CF 9+ Use this value to specify the name of the secondary cache.

saveMapping

Required: No
Default: NO
CF 9+ Specifies whether the generated Hibernate mapping file has to be saved to disk. If you set the value to true, the Hibernate mapping XML file is saved with the filename "CFC name".hbm.xml in the same directory as the CFC.

accessors

Required: No
CF 9+ If set to false, ColdFusion ORM does not generate the implicit getters and setters.

serializable

Required: No
CF 9+ Specifies whether this component can be serialized. If you set this value to false, the component and the data in the component‚ This and Variables scopes cannot be serialized, so they are not retained on session replication, and the component is in its default state.

attribute

Required: No
Default: YES
CF 9+ If the attribute is set to false at the component level, then the implicit getters and setters for the individual properties are ignored.

mappedSuperClass

Required: No
Default: false
CF 9.0.1+ When true on a non persistant CFC, CFCs that extend this component can inherit properties.

Compatibility

ColdFusion:

Version 6+ CFCs Introduced including support for SOAP web services.
CF 9+ Hibernate ORM support and script based CFCs.
CF 10+ REST Services

Links more information about cfcomponent

Examples sample code using the cfcomponent tag


Script Syntax

CF 9+

component displayname="Script Widget" output="false" { 
 // functions and properties here 
}

Tag Syntax

<cfcomponent displayname="Tag Widget" output="false"> 
    <!--- functions and other values here ---> 
</cfcomponent>

Fork me on GitHub