Monday, July 18, 2011

Salesforce VisualPage CommandLink

<apex:page controller="CreateOpportunity_controller" action="{!createOpportunity}">
<apex:form >
<apex:commandLink action="{!redirectToOpportunity}" value="Open Opportunity" rendered="{!displayOppLink}" />
</apex:form>
</apex:page>

  • Has to be inside apex:form
  • redirectToOpportunity is the function in CreateOpportunity_controller class. This function can use PageReference object for redirection.
  • rendered attribute checks for true / false value of displayOppLink. Other option is rendered="{!IF(contains(caseField, "Contact"), true, false)}"