Activity Forums Salesforce® Discussions What is a command link and an output link in Salesforce ?

  • shariq

    Member
    September 3, 2018 at 2:07 pm

    Hi Anurag,

    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.
    Example - <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.
    Example -<apex:outputLink value="https://www.salesforce.com" id="theLink">www.salesforce.com</apex:outputLink>

    Hope that helps

  • Parul

    Member
    September 3, 2018 at 5:08 pm

    Apex:commandLink>:This tag creates a link that helps to execute an action defined in a controller.  Normally action can be executed using buttons but in situations where you need links to be placed on your page we can use this tag. Similar to the command button tag action method, this links also transfers control to a different 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.

    To add query string parameters to an < apex:commandLink >, specify them in the associated action method attribute.

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

    Apex:outputLink – The <h:outputLink> renders a fullworthy HTML <a> element with the proper URL in the href attribute which fires a bookmarkable GET request. It cannot directly invoke a managed bean action method.

    <apex:outputlink value=”https://www.google.co.in”> Google </apex:outputlink>

    <apex:outputlink value=”/{!r.Id}”> {!r.Name} </apex:outputlink>

     

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos