function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Robert RobinsonRobert Robinson 

apex:commandlink question

I am using an apex:Pageblock with a 6 column panelgrid to create pagination for a custom related list. I have everything working ok except for 1 piece. I created a "Go to List" function that pulls up the list of related records. So that this will appear, I am using the apes:commandLink value function as follows:
  <apex:commandLink value="Go to List" rendered="{!units.hasNext}" action="{!showAll}"/>
This block gives users these options: Go to List  Next  Last on page 1, Go to List First Previous Next Last on page 2 and so on. On the last page, the user sees First  Previous as options 
I think this is where i painted myself into a corner; the Go to List option appears only as long as there is a "Next" option; on the last page (no next), Go to List is not an option.

Here is the pertinent block of code:
 </apex:pageBlockButtons> 
      <apex:panelGrid columns="6" id="linkPanel">
        <apex:commandLink value="Go to List" rendered="{!units.hasNext}" action="{!showAll}"/>       
        <apex:commandLink status="fetchStatus" reRender="pblock" action="{!first}" value="First" rendered="{!units.hasPrevious}"/>
        <apex:commandLink status="fetchStatus" reRender="pblock" action="{!previous}" rendered="{!units.hasPrevious}" value="Previous"/>
        <apex:commandLink status="fetchStatus" reRender="pblock" action="{!next}" rendered="{!units.hasNext}" value="Next"/>
        <apex:commandLink status="fetchStatus" reRender="pblock" action="{!last}" rendered="{!units.hasNext}" value="Last"/>
        <apex:outputText id="pNum">{!IF(noofrecords=0,'No records to display',TEXT((units.pageNumber * size)+1-size)+'-'+IF((units.pageNumber * size)>noOfRecords, TEXT(noOfRecords),TEXT((units.pageNumber * size)))+' of '+ TEXT(noofrecords))}</apex:outputText>
        <apex:outputPanel style="color:#4AA02C;font-weight:bold">
        <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
        </apex:outputPanel>
      </apex:PanelGrid>
    </apex:pageBlock>

Is there another function that I can use to ensure that the Go to Link option appears on the last page of the list? Thanks.
Best Answer chosen by Robert Robinson
Surendra Choudhary 1Surendra Choudhary 1
Hi Robert,

You can you below statement:

<apex:commandLink value="Go to List" rendered="{!units.hasNext || units.hasPrevious}" action="{!showAll}"/>

Please try this and let me know.

Thanks,
Surendra

All Answers

Surendra Choudhary 1Surendra Choudhary 1
Hi Robert,

You can you below statement:

<apex:commandLink value="Go to List" rendered="{!units.hasNext || units.hasPrevious}" action="{!showAll}"/>

Please try this and let me know.

Thanks,
Surendra
This was selected as the best answer
Robert RobinsonRobert Robinson
Thank you, thank you, thank you!!!
Could you tell me what the pipe (||) function does? Is it a short hand for OR? 
Did I say thank you?
Surendra Choudhary 1Surendra Choudhary 1
Hi Robert,

Yes its short hand OR operator. 

Welcome again !!

Regards,
Surendra
Robert RobinsonRobert Robinson
Thank you very much for the knowledge!