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
samnshsamnsh 

can some explain this code...??

Why do we use setcon.first and "disabled="{!!setCon.hasPrevious}"...why this is used...please help..i am new to apex....also setcon.first is inbulit method...

 

 

 

 

<apex:commandButton status="fetchStatus" reRender="op1" value="First" action="{!setCon.first}" disabled="{!!setCon.hasPrevious}" title="First Page"/>
<apex:commandButton status="fetchStatus" reRender="op1" value="Previous" action="{!setCon.previous}" disabled="{!!setCon.hasPrevious}" title="Previous Page"/>
<apex:commandButton status="fetchStatus" reRender="op1" value="Next" action="{!setCon.next}" disabled="{!!setCon.hasNext}" title="Next Page"/>
<apex:commandButton status="fetchStatus" reRender="op1" value="Last" action="{!setCon.last}" disabled="{!!setCon.hasNext}" title="Last Page"/>

vishal@forcevishal@force

Hi Samnsh,

 

As you can see these commandButtons are used for pagination. So the disabled attribute is being used here to ensure that a user cannot click on next page button if there are not enough records on the first page itself.

 

For example :

If there are 50 records and on each page, you are having 10 records, you will have 5 pages. From first page, you should not be able to click on previous (so you use disabled attribute).

Similarly, from your last page, there is no "next page", so you are making sure the next page button is disabled.

 

hasPrevious and hasNext are boolean variables, they are set to "TRUE" if there is a next/previous page, else they are set to false.

 

Based on these values, if hasPrevious is false means there is no previous page, so the previous page button is set to disabled,ie, user cannot click on it.

 

Hope this helps. Let me know if you still have any doubts!