You need to sign in to do that
Don't have an account?

I want to display Previous and Next buttons in object record display page
Hi all,
I generate the code for displaying the records of object choosen in picklist field (Lead and Contact)
Actually i want to add Previous and Next buttons after dipalying the records..
Example if have 50 records first it will displayed only 10 records for next records we should have Next Or previous buttons...........
Here is my code...
Apex class :
public class objectcontroller
{
public List<selectOption> objects{get; set;}
public string selected{get; set;}
public List<contact> obj1{get; set;}
public list<lead> obj2{get; set;}
public boolean obj1Status{get; set;}
public boolean obj2Status{get; set;}
public list<wrapcontact> wrapcon{get;set;}
public list<wrapLead> wrapLd{get;set;}
public objectcontroller()
{
obj1Status=false;
obj2Status=false;
objects= new List<selectOption>();
objects.add(new selectOption('contact','contact'));
objects.add(new selectOption('lead','lead'));
wrapcon = new List<wrapcontact>();
wrapLd = new list<wrapLead>();
}
public pageReference getRecordofObject()
{
if(selected=='contact')
{
for(contact c :[select id,lastname,Email from contact limit 100]){
wrapcon.add(new wrapcontact(c));
}
obj1Status=true;
obj2status=false;
}
else
{
for(lead l:[select name,company,Status from lead limit 100]){
wrapLd.add(new wrapLead(l));
}
obj1status=false;
obj2Status=true;
}
return null;
}
public class wrapcontact {
public contact con {get; set;}
public Boolean selected {get; set;}
public wrapcontact(contact a) {
con = a;
selected = false;
}
}
public class wraplead{
public lead Ld {get; set;}
public Boolean selected {get; set;}
public wraplead(lead a) {
Ld = a;
selected = false;
}
}
}
Visulaforce page :
<apex:page controller="objectcontroller" showHeader="false">
<apex:form >
<apex:pageBlock title="Select a object">
<apex:selectList value="{!selected}" size="1">
<apex:selectOptions value="{!objects}"/>
</apex:selectList>
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!getRecordofObject}" value="Show Records" rerender="cb"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:outputPanel >
<apex:pageBlock id="cb">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!wrapcon}" var="ob1" rendered="{!obj1Status}">
<apex:column >
<apex:inputCheckbox value="{!ob1.selected}" id="inputId"/>
</apex:column>
<apex:column value="{!ob1.con.id}"/>
<apex:column value="{!ob1.con.lastname}"/>
<apex:column value="{!ob1.con.Email}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!wrapLd}" var="ob2" rendered="{!obj2Status}">
<apex:column >
<apex:inputCheckbox value="{!ob2.selected}" id="inputId"/>
</apex:column>
<apex:column value="{!ob2.Ld.id}"/>
<apex:column value="{!ob2.Ld.company}"/>
<apex:column value="{!ob2.Ld.status}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>
Thanks in advance.......
I generate the code for displaying the records of object choosen in picklist field (Lead and Contact)
Actually i want to add Previous and Next buttons after dipalying the records..
Example if have 50 records first it will displayed only 10 records for next records we should have Next Or previous buttons...........
Here is my code...
Apex class :
public class objectcontroller
{
public List<selectOption> objects{get; set;}
public string selected{get; set;}
public List<contact> obj1{get; set;}
public list<lead> obj2{get; set;}
public boolean obj1Status{get; set;}
public boolean obj2Status{get; set;}
public list<wrapcontact> wrapcon{get;set;}
public list<wrapLead> wrapLd{get;set;}
public objectcontroller()
{
obj1Status=false;
obj2Status=false;
objects= new List<selectOption>();
objects.add(new selectOption('contact','contact'));
objects.add(new selectOption('lead','lead'));
wrapcon = new List<wrapcontact>();
wrapLd = new list<wrapLead>();
}
public pageReference getRecordofObject()
{
if(selected=='contact')
{
for(contact c :[select id,lastname,Email from contact limit 100]){
wrapcon.add(new wrapcontact(c));
}
obj1Status=true;
obj2status=false;
}
else
{
for(lead l:[select name,company,Status from lead limit 100]){
wrapLd.add(new wrapLead(l));
}
obj1status=false;
obj2Status=true;
}
return null;
}
public class wrapcontact {
public contact con {get; set;}
public Boolean selected {get; set;}
public wrapcontact(contact a) {
con = a;
selected = false;
}
}
public class wraplead{
public lead Ld {get; set;}
public Boolean selected {get; set;}
public wraplead(lead a) {
Ld = a;
selected = false;
}
}
}
Visulaforce page :
<apex:page controller="objectcontroller" showHeader="false">
<apex:form >
<apex:pageBlock title="Select a object">
<apex:selectList value="{!selected}" size="1">
<apex:selectOptions value="{!objects}"/>
</apex:selectList>
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!getRecordofObject}" value="Show Records" rerender="cb"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:outputPanel >
<apex:pageBlock id="cb">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!wrapcon}" var="ob1" rendered="{!obj1Status}">
<apex:column >
<apex:inputCheckbox value="{!ob1.selected}" id="inputId"/>
</apex:column>
<apex:column value="{!ob1.con.id}"/>
<apex:column value="{!ob1.con.lastname}"/>
<apex:column value="{!ob1.con.Email}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!wrapLd}" var="ob2" rendered="{!obj2Status}">
<apex:column >
<apex:inputCheckbox value="{!ob2.selected}" id="inputId"/>
</apex:column>
<apex:column value="{!ob2.Ld.id}"/>
<apex:column value="{!ob2.Ld.company}"/>
<apex:column value="{!ob2.Ld.status}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>
Thanks in advance.......
Please refer below links which might help you in this.
https://www.forcetalks.com/blog/salesforce-visualforce-custom-pagination-without-using-offset-in-salesforce/
https://salesforcescool.blogspot.com/2017/03/pagination-without-standard-controller.html
Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.
Thanks and Regards