Technology has always been a bridge, but today, it feels more like a mirror. With the rapid rise of AI , we are seeing things enter our lives and leave them at a pace we can barely track. To understand where this is going, we first have to understand how technology actually impacts the core of who we are. The Survivalist vs. The Ego Our minds are biologically wired for one thing: survival . We are designed to handle the worst-case scenario, an ancient instinct gifted to us by nature. We consider ourselves conscious decision-makers, but a critical question remains: Who is really making the call?
Want to develop pagination with help of standard set controller and wrapper class in salesforce. here is code:-
| Pagination in Visualforce page with wrapper class |
Step 1:- Create a class with help of below code.
public class ClassWithStandardSetController {
Public Integer noOfRecords{get; set;}
Public Integer size{get;set;}
List<SelectedWrapper> categories {get;set;}
public ApexPages.StandardSetController setCon {
get{
if(setCon == null){
size = 5;
setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT id,LineNumber,PriceBookEntry.Product2Id, PriceBookEntry.Product2.Name,Product2Id,Quantity,unitprice,QuoteId FROM quoteLineItem]));
setCon.setPageSize(size);
noOfRecords = setCon.getResultSize();
}
return setCon;
}set;
}
Public List<SelectedWrapper> getLineitems(){
categories = new List<SelectedWrapper>();
for (quoteLineItem category : (List<quoteLineItem>)setCon.getRecords())
categories.add(new SelectedWrapper(category));
return categories;
}
public PageReference Yourmethod() {
System.debug('Hi! Welcome');
refresh();
return null;
}
public pageReference refresh() {
setCon = null;
getLineitems();
setCon.setPageNumber(1);
return null;
}
public Boolean hasNext {
get {
return setCon.getHasNext();
}
set;
}
public Boolean hasPrevious {
get {
return setCon.getHasPrevious();
}
set;
}
public Integer pageNumber {
get {
return setCon.getPageNumber();
}
set;
}
public void first() {
setCon.first();
}
public void last() {
setCon.last();
}
public void previous() {
setCon.previous();
}
public void next() {
setCon.next();
}
public class SelectedWrapper{
public Boolean checked{ get; set; }
public quoteLineItem quotelineiteobj { get; set;}
public SelectedWrapper(quoteLineItem olineitem){
quotelineiteobj = olineitem;
checked = false;
}
}
}
Step 2:- Create a Visualforce page with help of below code.
<apex:page controller="ClassWithStandardSetController" sidebar="false">
<apex:form >
<style>
.Processing
{
position: fixed;
background: url('/img/loading32.gif');
background-repeat: no-repeat;
background-position: center;
width: 100%;
height: 100%;
z-index: 1004;
left: 0%;
top: 0%;
}
</style>
<apex:actionStatus id="statusProcessing" startStyleClass="Processing"/>
<apex:outputPanel id="Msg">
<apex:pagemessages ></apex:pagemessages>
</apex:outputPanel>
<apex:pageBlock title="{!$ObjectType.quoteLineItem.LabelPlural} Page #{!pageNumber}">
<apex:pageBlockButtons rendered="{!if(Lineitems.size>0, true, false)}" >
<apex:commandButton value="Your method" action="{!Yourmethod}" rerender="table,Msg" status="statusProcessing" />
</apex:pageBlockButtons>
<apex:pageMessage severity="error" summary="There is no Quote Line Items." rendered="{!if(Lineitems.size==0, true, false)}"></apex:pageMessage>
<apex:pageBlockTable value="{!Lineitems}" var="c" title="{!$ObjectType.quoteLineItem.LabelPlural}" id="table" rendered="{!if(Lineitems.size>0, true, false)}">
<apex:column width="25px">
<apex:inputCheckbox value="{!c.checked}"/>
</apex:column>
<apex:column value="{!c.quotelineiteobj.PriceBookEntry.Product2.Name}" headerValue="Name"/>
<apex:column headerValue="{!$ObjectType.Product2.LabelPlural}" value="{!c.quotelineiteobj.PriceBookEntry.Product2.Name}"/>
<apex:column value="{!c.quotelineiteobj.QuoteId }" />
<apex:column value="{!c.quotelineiteobj.Quantity}" />
<apex:column value="{!c.quotelineiteobj.unitprice}" />
</apex:pageBlockTable>
</apex:pageBlock>
<apex:panelGrid columns="4" >
<apex:commandLink action="{!first}">First</apex:commandlink>
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
<apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
<apex:commandLink action="{!last}">Last</apex:commandlink>
</apex:panelGrid>
</apex:form>
</apex:page>