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
RajashriRajashri 

Print list in visual force page

Hi,

i am trying to print the campaign member list in my vf page but it's giving me an error
Can anyone please help me?
below is my code..
<apex:page StandardController="Campaign"  extensions="CampaignMemController">
    <apex:form >
        <apex:pageBlock title="Campaign Members Details" mode="maindetail">
            <apex:pageBlockSection title="Campaign Members"  id="cm3">
                <apex:pageblocktable value="{!cm}" var="lead">
                        <apex:column headerValue="Name">
                            <apex:outputfield value="{!lead.Id}" />
                        </apex:column>
    
   </apex:pageblocktable>
                      </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
 
public with sharing class CampaignMemController {

    public Campaign camp {get; set; }
    list<contact> con = [SELECT id FROM contact];
    
    list<campaignmember> cmlist = [SELECT id, contactid FROM campaignmember];
    list<contact> conlist = new list<contact>();
     public CampaignMemController(ApexPages.StandardController controller) {
         camp  = (Campaign)controller.getRecord();
  
  
    for(campaignmember cm : cmlist)
{
     for(contact c : con)
    {
             if(c.id == cm.contactid)
                              conlist.add(c);
     }
    
//System.debug('All the campaignmemebers under contact '+con.name+'are'+camList );
        }  
    } 

}
Hargobind_SinghHargobind_Singh
What is the error ?
Roy LuoRoy Luo
cm is not definded in your controller. 
 <apex:pageblocktable value="{!cm}" var="lead">

You would need to add something like this to your controller
public List<sObject> cm {get; set;}

and assign the values somewhere.
RajashriRajashri
Ok..i want to print the campaign members list..How can i do that
Naveen Rahul 3Naveen Rahul 3

Hi Rajashri,

check this one, looking for try eradicate the duplicates

<apex:page StandardController="Campaign"  extensions="CampaignMemController">
    <apex:form >
        <apex:pageBlock title="Campaign Members Details" mode="maindetail">
            <apex:pageBlockSection title="Campaign Members"  id="cm3">
                 <apex:pageblocktable value="{!cm}" var="lead">
                        <apex:column headerValue="Name">
                            <apex:outputfield value="{!lead.name}" />
                        </apex:column>
    
               </apex:pageblocktable>   
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


public with sharing class CampaignMemController {

    public Campaign camp {get; set; }
    list<contact> con = [SELECT id,name FROM contact];
    public List<contact> cm {get; set;}
    list<campaignmember> cmlist = [SELECT id, contactid FROM campaignmember];
    list<contact> conlist = new list<contact>();
    
     public CampaignMemController(ApexPages.StandardController controller) {
         camp  = (Campaign)controller.getRecord();
 
 
        for(campaignmember cm : cmlist)
        {
             for(contact c : con)
            {
                     if(c.id == cm.contactid){
                         conlist.add(c);
                     }
             }
    

        }  
        cm =conlist;
        System.debug('All the campaignmemebers under contact '+conlist+'are');
        System.debug('Test value of CM'+cm);
         
        
    }

}

 

 

RajashriRajashri
Hi Naveen..
Thanks Name field comes fine but I want to print the Campaign member list that's 'Contactid 'fields from below query

  list<campaignmember> cmlist = [SELECT id, contactid FROM campaignmember];

How can i do that?
VempallyVempally
Hi...

try these...

<apex:pageblocktable value="{!conlist}" var="lead">

<apex:pageblocktable value="{!con}" var="lead">
 
RajashriRajashri
I naveen ..we don't have skype access
can you give me your gtalk id?

 
Naveen Rahul 3Naveen Rahul 3

might be this will be helpfull.

http://iwritecrappycode.wordpress.com/2010/10/01/simple-list-editor-visualforce-page/
 

RajashriRajashri
Sent you the Gmail Invitation