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
Varun99Varun99 

pagination in visual force page

Hi,

      I have developed a vf page displaying contacts with pagination when i click on contact names 

it will show detail page of particular contact. But i want pagination in this detaipage only. it means 

wnen i click on next button it will show next contact detail page so on...

Please help me

Thank you.

 

<apex:page controller="contactstoupdate" showHeader="false" sidebar="false">
<apex:form id="abc" >
<apex:sectionHeader Title="Contact" subtitle="There are a total of {!reccount} Records in this List"/>
<apex:pageBlock rendered="{!clist}" title="Contact Results - Page #{!pagenumber}" >
<apex:pageBlockTable value="{!conlist}" var="acc" >
<apex:column headerValue="Contacts" >
<apex:commandLink value="{!acc.name}" action="{!condetail}">
<apex:param name="conname" value="{!acc.id}"/>
</apex:commandlink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:panelGrid columns="4" rendered="{!abc}">
<apex:commandLink action="{!first}" ><b>First</b></apex:commandlink>
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}"><b>Previous</b></apex:commandlink>
<apex:commandLink action="{!next}" rendered="{!hasNext}"><b>Next</b></apex:commandlink>
<apex:commandLink action="{!last}"><b>Last</b></apex:commandlink>
</apex:panelGrid>
<apex:pageblock rendered="{!condetail}" title="Contact detail page" >
<apex:pageBlockButtons >
<apex:commandButton value="Edit" action="{!Edit}" />
<apex:commandButton value="back" action="{!page}" />
</apex:pageBlockButtons>
<apex:pageblockSection >
<apex:outputField value="{!con.lastname}"/>
<apex:outputField value="{!con.phone}"/>
<apex:outputField value="{!con.email}"/>
</apex:pageblockSection>
</apex:pageblock>
<apex:panelGrid columns="2" rendered="{!bcc}">
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}"><b>Previous</b></apex:commandlink>
<apex:commandLink action="{!next}" rendered="{!hasNext}"><b>Next</b></apex:commandlink>
</apex:panelgrid>
<apex:pageBlock rendered="{!conedit}">
<apex:pageblockButtons >
<apex:commandButton value="save" action="{!save}"/>
<apex:commandButton value="back" action="{!back}"/>
</apex:pageblockButtons>
<apex:pageblockSection >
<apex:inputField value="{!con.lastname}"/>
<apex:inputField value="{!con.phone}"/>
<apex:inputField value="{!con.email}"/>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

==============================================================================

 

public class contactstoupdate
{
public boolean clist{set;get;}
public boolean condetail{set;get;}
public boolean conedit{set;get;}
public boolean abc{set;get;}
public boolean bcc{set;get;}
//public boolean hasprevious{set;get;}
//public boolean hasnext{set;get;}
//list<contact> conlist=new list<contact>();

contact con=new contact();
public contactstoupdate()
{
clist=true;
abc=true;
condetail=false;
conedit=false;
//for(contact c:[select id,name from contact])
//conlist.add(c);
//system.debug('@@@@@@'+conlist);
}

public ApexPages.StandardSetController con1 {
get {
if(con1==null)
{
con1 = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name,lastname,phone,email FROM Contact limit 100]));
// sets the number of records in each page set
con1.setPageSize(5);
system.debug('@@@@@@'+con1);
}
return con1;

}
set;

}

public Boolean hasNext{get{return con1.getHasNext();}set;}
//public Boolean hasNextpage{get{return con.getHasNextpage();}set;}
//public Boolean haspreviouspage{get{return con.getHasNextpage();}set;}

public Boolean hasPrevious{get{return con1.getHasPrevious();}set;}
public Integer pageNumber{get{return con1.getPageNumber();}set;}

public Integer getReccount() {
return Con1.getResultSize();
}
public list<contact> getconlist()
{
return con1.getrecords();
}
public void condetail()
{
bcc=true;
clist=false;
abc=false;
condetail=true;
id i=Apexpages.currentpage().getparameters().get('conname');
con = [select id,lastname,phone,email from contact where id=:i];
}
public void edit()
{
conedit=true;
condetail=false;
clist=false;
}
public void back()
{
condetail=true;
conedit=false;
clist=false;
}
public void page()
{
bcc=false;
clist=true;
abc=true;
condetail=false;
conedit=false;
con1 = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name FROM Contact limit 100]));
con1.setPageSize(5);
}
public void save()
{
condetail=true;
conedit=false;
clist=false;
update con;
}
public contact getcon()
{
return con;
}
public void first()
{
con1.first();
}
public void previous()
{
con1.previous();
}
public void next()
{
con1.next();
}
public void last()
{
con1.last();
}
public void previouspage()
{

}

}

Sourabh_Master10Sourabh_Master10

Hi,

See these links:-
http://blog.jeffdouglas.com/2009/07/14/visualforce-page-with-pagination/

if you think that answer is right then please tick the answers.
Thanks
Sourabh