Javatpoint Logo
Javatpoint Logo

component in Visualforce Page

The <apex: attribute> component is another important component that is used for specifying a definition of an attribute on a custom component. The <apex: attribute> can only be a child of a component tag only.

The <apex: attribute> component has the following attributes:

1. access

It is one of the most important attributes that is used for specifying whether we can access this attribute outside of any page in the same namespace or not. The public and global are two possible values for it.

Syntax:

2. assignTo

It is of type Object that is used for specifying the setter method. The setter method is responsible for assigning the value of this attribute to a class variable in the associated custom component controller.

Syntax:

3. default

It is of type string that is used for specifying the default value for this attribute.

Syntax:

4. description

It is of type string that is used for specifying the text description of the attribute.

Syntax:

5. id

It is of type string that is a unique identifier for allowing this attribute to be referenced by other tags in the custom component definition.

Syntax:

6. name

It is of type string that is used for specifying the name of the attribute. By using the name of the attribute, we can use it in VF markup when the associated custom component includes a value for the attribute.

Syntax:

7. required

It is of type Boolean that is used for specifying whether the attribute value must be provided by the user or not when the associated custom component is included in a VF page. By default, its value is set to false.

Syntax:

8. type

It is of type string that is used for specifying the data type of the attribute. It can be primitives, sObject, one-dimensional lists, maps, or custom apex types.

Syntax:

Let's take an example to understand how we can use the <apex: attribute> component in VF:

ApexAttributeExample.vfp

ApexAttributeComponent.vfc

ApexAttributeController.apxc

Output

apex:attribute component in Visualforce Page





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA