• Sourabh_Master10
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies

Hi,

     I am displaying all contacts using list in a pageblock table. and when i click on contact names

it will show the output fields(detail page) of particular record. So i want to pagination in this detail page

next, previous clicking on next it will show next record detail page.clicking on previous it will show previous recored detail page. so how to add the displaying contact list to pagination query.

 

please help me.

 

My code

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

<apex:page controller="classcon" sidebar="false" showHeader="false">
<apex:form >
<apex:pageBlock rendered="{!clist}">
<apex:dataTable value="{!conlist}" var="c" >

<apex:column headerValue="contacts" >
<apex:commandLink value="{!c.name}" action="{!condetail}">
<apex:param name="conname" value="{!c.id}"/>
</apex:commandLink>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
<apex:pageBlock rendered="{!cdetail}" >
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="edit" action="{!edit}"/>
<apex:commandButton value="back" action="{!back}"/>
</apex:pageBlockButtons>
<apex:pageblockSection >
<apex:repeat value="{!con2}" var="ac">
<apex:param value="{!ac.id}"/>
<apex:outputfield value="{!ac.lastname}"/>
<apex:outputfield value="{!ac.phone}"/>
<apex:outputfield value="{!ac.email}"/>
</apex:repeat>
</apex:pageblockSection>
</apex:pageBlock>
<apex:panelGrid >
<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="{!cedit}" >
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="save" action="{!save}"/>
<apex:commandButton value="back" action="{!back}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:repeat value="{!con2}" var="ab">
<apex:inputfield value="{!ab.lastname}"/>
<apex:inputfield value="{!ab.phone}"/>
<apex:inputfield value="{!ab.email}"/>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

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

public class classcon {
list<contact> conlist=new list<contact>();
public boolean clist {set;get;}
public boolean cdetail{set;get;}
public boolean cedit{set;get;}
//public boolean bcc{set;get;}
public ApexPages.StandardSetController con1{set;get;}
//list<contact> con=new list<contact>();

public classcon(){
clist=true;
cdetail=false;
cedit=false;

conlist=[select id,lastname,name,phone,email from contact];
}
public list<contact> getconlist(){return conlist;}
public Boolean hasNext{get{return con.getHasNext();}set;}
public Boolean hasPrevious{get{return con.getHasPrevious();}set;}

public ApexPages.StandardSetController con {
get {
if(con==null)
{
con = new ApexPages.StandardSetController(Database.getQueryLocator([Select id,name,lastname,phone,email FROM Contact where id in:conlist]));
con.setPageSize(1);
system.debug('@@@@@@'+con);
}
return con;

}
set;

}

public void condetail()
{

id i=apexpages.currentpage().getparameters().get('conname');
system.debug('+++++++++++++++++++++'+con);
clist=false;
cdetail=true;
cedit=false;

con2=new contact();
con2=[select id,lastname,phone,email from contact where id=:i];
}
public contact con2{get;set;}


public void edit()
{
clist=false;
cdetail=false;
cedit=true;
}

public void save(){

clist=false;
cdetail=true;
cedit=false;
update con2;
}
public void back(){

clist=true;
cdetail=false;
cedit=false;
}
public void next()
{

con.next();
}
public void previous()
{
con.previous();
}
}

 

 

 

Hi all,

        I am new to development, what is the wrapper class, how is useful in  visualforce pages and apex classes, any one can help me with  one simple example , help would appreciated

 

 

Thanks,

Nageswar.

 

 

How to use apex:component (also please help me how to use apex:attribute in apex:component )

I reefed - http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_attribute.htm

 

<apex:page> </apex:page> 
<apex:component>
<!--<apex:attribute name="myValue" description="This is the value for the component." type="String" required="true"/> -->
</apex:component>

 this is the code i try to do but i am getting this error :

 

 

ErrorError: componet line 2, column 2: The markup in the document following the root element must be well-formed 
Error

Error: The markup in the document following the root element must be well-formed.

 

 

thanks

Anuraj

Hi...... How can i create different colors for every page block section in vf 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()
{

}

}