Activity Forums Salesforce® Discussions What is the difference between apex command link and apex output link in Salesforce? Reply To: What is the difference between apex command link and apex output link in Salesforce?

  • Aman

    Member
    July 19, 2017 at 1:14 pm

    Hello Shariq,

    apex:commandLink:
    A link that executes an action defined by a controller, and then either refreshes the current page, or navigates to a different page based on the PageReference variable that is returned by the action. An <apex:commandLink> component must always be a child of an <apex:form> component.

    eg.
    <apex:commandLink action="{!save}" value="Save" id="theCommandLink"/>

    apex:outputLink:
    A link to a URL. This component is rendered in HTML as an anchor tag with an href attribute. Like its HTML equivalent, the body of an <apex:outputLink> is the text or image that displays as the link. To add query string parameters to a link, use nested<apex:param> components.

    eg.
    <apex:outputLink value="https://www.salesforce.com" id="theLink">www.salesforce.com</apex:outputLink>