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
extends string
Name of parent component from which to inherit methods and properties.
output boolean
Specifies whether constructor code in the component can generate HTML output; does not affect output in the body of cffunction tags in the component.
Values:
truefalse
displayname string
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 string
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 string
Default: rpc
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:
rpcdocument
namespace string
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 string
CF 7+ Specifies the name of the port element in the WSDL. This attribute applies only when style="document".
porttypename string
CF 7+ Specifies the name of the porttype element in the WSDL. This attribute applies only when style="document".
bindingname string
CF 7+ Specifies the name of the binding element in the WSDL. This attribute applies only when style="document".
wsdlfile string
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 string
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 string
CF 8+ Specifies the SOAP URL of the web service.
initmethod string
CF 9+ Method that will be called when ColdFusion instantiates the component
persistent boolean
CF 9+ Specifies CFC is persistent or not
Values:
truefalse
entityname string
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 string
CF 9+ Specifies the name of the database table to which the CFC maps.
schema string
CF 9+ Used to specify the schema name.
catalog string
CF 9+ Used to specify the database catalog name.
dynamicinsert boolean
Default: false
false
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.
Values:
truefalse
dynamicupdate boolean
Default: false
false
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.
Values:
truefalse
readonly boolean
CF 9+ Specify whether table is readonly or not
Values:
truefalse
selectbeforeupdate boolean
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.
Values:
truefalse
batchsize numeric
CF 9+ An integer value that specifies the number of records to be retrieved at a single instance.
optimisticlock string
Default: version
version
CF 9+ Determines the locking strategy.It can be any one of the following four values:noneversiondirtyall
Values:
nonedirtyallversion
lazy boolean
Default: true
true
CF 9+ Whether loading is to be done lazily or not.
Values:
truefalse
rowid string
CF 9+ Row id
discriminatorColumn string
CF 9+ Use this attribute to define the discriminator column to be used in inheritance mapping
discriminatorValue string
CF 9+ Use this attribute to define the discriminator value to be used in inheritance mapping
joinColumn string
CF 9+ Use this attribute to define the join column for inheritance mapping.
embedded boolean
CF 9+ Marks CFC as embedded, used when a CFC has an embedded object which also needs to be persisted along with the parent's data
Values:
truefalse
cacheUse string
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-onlynonstrict-read-writeread-writetransactional
cacheName string
CF 9+ Use this value to specify the name of the secondary cache.
saveMapping boolean
Default: false
false
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.
Values:
truefalse
accessors boolean
CF 9+ If set to false, ColdFusion ORM does not generate the implicit getters and setters.
Values:
truefalse
serializable boolean
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.
Values:
truefalse
attribute boolean
Default: true
true
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.
Values:
truefalse
mappedSuperClass boolean
Default: false
false
CF 9.0.1+ When true on a non persistent CFC, CFCs that extend this component can inherit properties.
Values:
truefalse
rest boolean
Default: false
false
CF 10+ Enables/disables REST.restPath must be specified to enable REST
Values:
truefalse
restPath string
CF 10+ Path to access the REST-API
Values:
truefalse
httpMethod string
CF 10+
Values:
GETPOSTPUTDELETEHEADOPTIONS
produces string
Default: /
/
CF 10+ Comma-separated list of acceptable MIME types for output
Values:
text/plain,text/html...
consumes string
Default: /
/
CF 10+ Comma-separated list of acceptable MIME types for input
Values:
text/plain,text/html...
indexable boolean
Default: false
false
CF 10+ Enables/disables indexing for the component
Values:
truefalse
indexLanguage string
Default: english
english
CF 10+ Set the language to be used to index and search
autoIndex boolean
Default: true
true
CF 10+ Enables/disables auto-indexing
Values:
truefalse
wsVersion numeric
CF 10+ Set the wsVersion of Axis engine
Values:
12
invokeImplicitAccessor boolean
Default: false
false
CF 2016+ Get and set component properties using getter and setter methods defined in the component
Values:
truefalse
Compatibility
ColdFusion:
Version 6+ CFCs Introduced including support for SOAP web services. CF9+ Hibernate ORM support and script based CFCs. CF10+ REST Services. CF2016+ Added invokeImplicitAccessor.
BoxLang:
Version 1.0.0+ There are no tag-based classes in BoxLang
Links more information about cfcomponent
- Object Oriented Programming Tutorial - Course from Learn CF In a Week
- Learning ColdFusion 9 ORM - Blog entry by Ben Nadel exploring ORM or Object Relational Mapping.
- ColdFusion ORM Book - A must have book if you are planning on using ORM / Hibernate in CFML
- CFC Implicit Notation - ACF documentation on using implicit accessors
Examples Sample code using the cfcomponent tag
CF 9+
component displayname="Script Widget" output="false" {
// functions and properties here
} <cfcomponent displayname="Tag Widget" output="false">
<!--- functions and other values here --->
</cfcomponent>
© 2012–present Foundeo, Inc. and the CFDocs contributors.
Licensed under the MIT License.
ColdFusion is a trademark of Adobe Systems Incorporated.
https://cfdocs.org/cfcomponent