+ Start a Discussion
Ashok S 7Ashok S 7 

how cani slove the below error

Hai,
Display records from 2 different object in a single table using Wrapper class
i created the vf page and controller
vf page
---------------------------
<apex:page controller="Wrapperclass_controller" >
 <apex:form >
 <apex:pageBlock >
 <apex:pageBlockSection >
 <apex:pageBlockTable value="{!lstwrapperstring}" var="ll">
 <apex:column headerValue="Action">
 <apex:inputCheckbox />
 </apex:column>
 
 <apex:column headerValue="Position Name">
 {!ll.pname}

 </apex:column>
 
 <apex:column headerValue="Job Description">
 {!ll.pjdescription}

 </apex:column>
 
 <apex:column headerValue="Location">
 {!ll.plocation}

 </apex:column>
 
 <apex:column headerValue="MAximum Pay">
 {!ll.pmaxpay}

 </apex:column>
 
 <apex:column headerValue="Candidate  FName">
 {!ll.cfname}
 
 </apex:column>
 
 <apex:column headerValue="Candidate LName">
 {!ll.clname}
 
 </apex:column>
 </apex:pageBlockTable>
 </apex:pageBlockSection>
 </apex:pageBlock>
 </apex:form>
</apex:page>

controller
-------------------------------
public class Wrapperclass_controller
{
      list<Position__c> plist = new list<Position__c>();
      list<Candidate__c> clist = new list<Candidate__c>();
      list<Wrapper> wlist = new list<Wrapper>();
      public list<Wrapper> getLstwrapperstring()
      {
        plist = [select Position_Name__c,Location__c,Job_Description__c,Max_Pay__c from Position__c limit 10];
        clist = [select     First_Name__c,Last_Name__c from Candidate__c];
        //integer p = plist.size();
        for(integer i=0; plist.size();i++)
        {
           wlist.add(new Wrapper(plist[i].Position_Name__c,plist[i].Location__c,plist[i].Job_Description__c,plist[i].Max_Pay__c,clist[i].First_Name__c,
                                          clist[i].Last_Name__c));
        }
        return wlist;
      }
       public class Wrapper
       {
          public string pname{get;set;}
          public string pjdescription{get;set;}
          public string plocation{get;set;}
          public decimal pmaxpay{get;set;}
          public string cfname{get;set;}
          public string clname{get;set;}
          public Wrapper(string pname,string pjdescription,string plocation,decimal pmaxpay,
                        string cfname,string clname)
          {
             this.pname= pname;
             this.pjdescription = pjdescription;
             this.plocation = plocation;
             this.pmaxpay = pmaxpay;
             this.cfname = cfname;
             this.clname = clname;
       
          }
        }
       
       
}

But when i saving the code it will display following error
Wrapperclass_controller Compile Error: Loop condition must be of type Boolean: Integer
i did not understand to slove this problem.please help me
Best Answer chosen by Ashok S 7
Neetu_BansalNeetu_Bansal
Hi Ashok,

Please change the for loop like this:
for(integer i=0; i<plist.size();i++)
Let me know, if you need any other help.

Thanks,
Neetu

All Answers

Neetu_BansalNeetu_Bansal
Hi Ashok,

Please change the for loop like this:
for(integer i=0; i<plist.size();i++)
Let me know, if you need any other help.

Thanks,
Neetu
This was selected as the best answer
William TranWilliam Tran
Your logic looks weird:

how do you now plist[2] corresponds to clist[2]?

plist is limited to 10, clist is not.

thx