Activity Forums Salesforce® Discussions 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>

  • saloni gupta

    Member
    July 19, 2017 at 1:19 pm

    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>

    apex:commandLink – The <h:commandLink> renders a HTML <a> element with an onclick script which submits a (hidden) POST form and can invoke a managed bean action method. It's also required to be placed inside a <h:form>.

    <apex:commandLink value="Google" action="https://www.google.co.in"/>

    <apex:commandLink value="Delete" action="{!dodelete}">
    <apex:param name="eid" value="{!E.Id}" assignTo="{!rId}"/>
    </apex:commandLink>

  • Parul

    Member
    September 16, 2018 at 7:26 am

    Hi

    Apex:outputLink: A link to a URL. apex:outputLink 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>

     

    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.
    To add request parameters to an <apex:commandLink>, use nested <apex:param> components.

    <apex:commandLink value="Google" action="https://www.google.co.in"/><apex:commandLink value="Delete" action="{!dodelete}">
    <apex:param name="eid" value="{!E.Id}" assignTo="{!rId}"/>
    </apex:commandLink>

     

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos