ApexComponent defines a reusable Visualforce user interface component that Visualforce pages and other components can reference. It is not an ApexClass, a complete Visualforce page represented by ApexPage, or the broader packaging term "component."
The asset includes both Visualforce markup and accompanying descriptive and versioning metadata. The markup contains expressions, bindings, and component references that determine much of its behavior. Reviewing only the metadata XML misses those connections.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
The component's developer-name identity for API access, not its label. It must be unique, begin with a letter, and contain only alphanumeric characters and underscores. Spaces, a trailing underscore, and consecutive underscores are not allowed. |
label |
Required. The component's label. It does not determine deployment identity. |
apiVersion |
The component's Visualforce API version, specified at creation. This is an asset setting, separate from the API version used for a metadata retrieval or deployment. |
content |
The component markup, inherited from MetadataWithContent. Metadata API transports this value as base64-encoded data; that transport format does not require storing the source markup file as base64. |
description |
A description of what the component does. |
packageVersions |
The installed managed package versions referenced by the component. These entries describe referenced packages, not versions of the Visualforce component itself. |
namespace |
Required within a package-version entry. Identifies the package namespace: a one- to 15-character alphanumeric identifier that distinguishes the package and its contents. Namespace prefixes are case-insensitive. |
majorNumber |
Required within a package-version entry. The major portion of the referenced package version. |
minorNumber |
Required within a package-version entry. Together with majorNumber, forms the package version in majorNumber.minorNumber format. |
Behavior and Constraints
Markup is part of the configuration. References to controllers, nested components, fields, labels, and resources can appear in the component's markup or expressions rather than as separate metadata properties. The descriptive XML alone is not a complete dependency inventory.
Shared components can have indirect consumers. A page can reference a component that references another component, Apex code, fields, or resources. Changing a shared component can therefore affect several pages, including pages connected through nested-component chains.
Component and package versions serve different purposes. apiVersion belongs to the Visualforce component. Each packageVersions entry identifies a referenced managed package by namespace and major/minor version. Neither setting is the API version chosen for the retrieve or deploy request.
Component boundaries should not be treated as runtime isolation. Community reports describe embedded components contributing to the hosting page's view state, the page state retained between requests. Splitting markup into reusable assets is not evidence that runtime view state will decrease.
Deployment and Retrieval
Visualforce component markup files use the .component suffix and reside in the components folder of the corresponding package directory. Each has accompanying metadata XML. Include the markup when inspecting a retrieved component; its metadata properties do not expose all expressions, bindings, or resource references.
ApexComponent supports the wildcard * in package.xml. To select components by type, use ApexComponent as the manifest type name and either the component's developer name or * as the member selector. The component's fullName, not its label, supplies its API identity.
For direct Metadata API content transport, clients encode content as base64 before sending it and decode it after receiving it. A SOAP client handles that conversion. Do not interpret the transport requirement as a requirement to base64-encode a stored .component source file.
Deployment scope depends on the actual markup references and on which assets and managed package versions already exist in the destination. The possible relationship types are not a mandatory deployment bundle and do not establish a fixed deployment order. A component that references a nested component requires a different dependency assessment from one that contains only self-contained markup.
Relationships
The following connections are content-based references represented by filedata. They can be embedded in markup or expressions rather than exposed as individual metadata properties. These are possible connections; the content of each asset determines which references actually exist.
References
-
ApexClass:filedata -
ApexComponent:filedata -
ApexPage:filedata -
CustomField:filedata -
CustomLabel:filedata -
CustomObject:filedata -
FieldSet:filedata -
Flow:filedata -
LightningMessageChannel:filedata -
StaticResource:filedata
Referenced By
-
ApexComponent:filedata -
ApexPage:filedata
Reported Issues
- Splitting a page into components might not reduce view state. In a 2018 discussion about dividing a large Visualforce page into components, contributors reported that embedded components contributed to the hosting page's view state. One example showed view state increasing after a component was added. Treat reuse and view-state reduction as separate concerns. View-state discussion.
-
Targeting a wrapper can resolve a component refresh problem. In a 2019 response about a component that did not refresh during an AJAX rerender, a partial page refresh, a contributor reported success after placing an
apex:outputPanelaround the component and targeting that wrapper for rerendering. This is a diagnostic option for that symptom, not a requirement to wrap every component. Wrapper rerender workaround. - A missing search result might not mean the component lacks the text. In a 2015 Developer Console "Search in Files" discussion, a contributor confirmed that the search could find Visualforce component content but reported inconsistent results for other terms known to occur in the markup. Retrieving the metadata and searching it locally was suggested as an alternative. Component search discussion.
Common Questions
How do I retrieve all Visualforce components?
Use ApexComponent in package.xml with * as the member selector. Component markup uses the .component suffix in the components folder and has accompanying metadata XML.
Which dependencies must I deploy with an ApexComponent?
Inspect the markup and expressions for referenced assets, including nested components. Deployment scope depends on those actual references and on the assets and managed package versions already present in the destination. The relationship list is not a required deployment bundle or order.
What is the difference between apiVersion and packageVersions?
apiVersion stores the component's Visualforce API version. packageVersions identifies referenced installed managed package versions by namespace and major/minor version. Neither is the API version used for the metadata request.
Does moving Visualforce markup into components reduce view state?
Not necessarily. Contributors in the 2018 discussion reported that embedded components contributed to the hosting page's view state, and one example showed an increase. Component modularity alone does not establish a reduction.
Why does my Visualforce component not refresh during rerender?
Wrapper targeting is one reported diagnostic consideration. A 2019 contributor resolved the symptom by wrapping the component in an apex:outputPanel and targeting that wrapper. The report does not establish a general cause or a universal wrapping requirement.