Display detail page using commandLink in Visualforce page

By | November 1, 2019

Hi, In this scenario we have shown how to display detail page of the record when we click on some field in output. Here we describes the usage of apex:commandLink and apex:param. Here param is used to pass individual record ids within the vf page to display detail page of the record.

Vf Page

<apex:page sidebar="false" standardController="Student__c" recordSetVar="rec">
  <apex:form >
      <apex:pageBlock >
          <apex:pageBlockSection >
              <apex:pageBlockTable value="{!rec}" var="r">
                  <apex:column headerValue="Name">
                    <apex:commandLink  rerender="out" status="mystatus">
                      {!r.Name}
                      <apex:param name="rId" value="{!r.Id}"/>
                      </apex:commandLink>
                  </apex:column>
                  <apex:column headerValue="City">
                      {!r.City__c}
                  </apex:column>
                  <apex:column headerValue="Country">
                      {!r.Country__c}
                  </apex:column>
                  <apex:column headerValue="phone">
                      {!r.Phone__c}
                  </apex:column>
          </apex:pageBlockTable>
          </apex:pageBlockSection>
      </apex:pageBlock>
      
      <apex:actionstatus id="mystatus" startText="loading.................">
          <apex:facet name="stop">
              <apex:outputpanel id="out">
                  <apex:detail subject="{!$CurrentPage.parameters.rId}" relatedList="false"/>
              </apex:outputpanel>  
          </apex:facet>
      </apex:actionstatus>
  </apex:form>
</apex:page>

Output

Click on name field Test, then detail page will be displayed below…
Share this...
Share on Facebook
Facebook
Email this to someone
email

Leave a Reply

Your email address will not be published.