function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chinni dchinni d 

what are vf component and whendo we use them?

Dutta SouravDutta Sourav
Hi Chinni,

In our projects, many times we develop codes which are required again and again. So instead of repeating same code again and again, we can create visualforce component. In other words, visualforce component allows us to create reusable component.

To Create VF Components,
Go to Setup -> Develop -> Visualforce Components and Create

Warm Regards,
Sourav
Amit Chaudhary 8Amit Chaudhary 8
apex:component
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_comp_cust_using.htm
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_comp_cust_elements_attributes.htm

A custom Visualforce component. All custom component definitions must be wrapped inside a single <apex:component> tag.

This component supports HTML pass-through attributes using the "html-" prefix. Pass-through attributes are attached to the generated container tag, <div> or <span>, depending on the layout attribute.
<!-- Page: -->

<apex:page>

    <c:myComponent myValue="My component's value" borderColor="red" />

</apex:page>



 <!-- Component:myComponent -->

<apex:component>

    <apex:attribute name="myValue" description="This is the value for the component."

        type="String" required="true"/>

    <apex:attribute name="borderColor" description="This is color for the border."

        type="String" required="true"/>

    <h1 style="border:{!borderColor}">

        <apex:outputText value="{!myValue}"/>

    </h1>

</apex:component>

Please let us know if this will help you

Thanks
Amit Chaudhary