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

I want a Wrapper class to display Account Object's 100 records and Opportunity Object's 40 records. How to write the For loop?
Wrapper class is for displaying the 2 different objects records in One tableor Objects with Checkbox.Till here It's clear.
My Question is
For example: I am using 2 objects say Account, Opportunity
While displaying all the Account and Opportunity records, i got a doubt that If Account have 100 records and Opportunity have 40 records.
Then How to write the Loop for that requirement ?
My Question is
For example: I am using 2 objects say Account, Opportunity
While displaying all the Account and Opportunity records, i got a doubt that If Account have 100 records and Opportunity have 40 records.
Then How to write the Loop for that requirement ?
Use below code.
Page
Controller
Please mark this as solution if this solves your problem, So that if anyone has this issue this can help.
All Answers
could you please explain more what and how exactly you want to show these records on page ? how these should come as in structure ? You need to show in a same row or column or differnt sections for Account and Opportunity ?
Here is a code you can use.
Also parents are always lessthan childs.
Please mark this as solution if this solves your problem, So that if anyone has this issue this can help.
My Requirement is to display All Account and All Opportunity Objects records in PageBlockTable. Here is my Code.
VF Page:
<apex:page controller="Pract2_2Objects">
<apex:form >
<apex:pageBlock >
<apex:pageblockTable value="{!Wrap}" var="w">
<apex:column value="{!w.aName}" />
<apex:column value="{!w.oName}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class Pract2_2Objects {
public List<Wrapper> wrap{set; get;}
public List<Account> acount{set; get;}
public List<Opportunity> oppor{set; get;}
public Pract2_2Objects(){
acount = [select name from Account];
oppor = [select name from opportunity];
wrap = new List<Wrapper>();
for(Integer i = 0 ; i< acount.size(); i++){
wrap.add(new Wrapper(acount[i].name, oppor[i].name)) ;
}
}
public Class Wrapper{
public String aName{set; get;}
public String oName{set; get;}
public Wrapper(String s1, String s2){
aName = s1;
oName = s2;
}
}
}
Use below code.
Page
Controller
Please mark this as solution if this solves your problem, So that if anyone has this issue this can help.
It's working fine for my requirement. Above code displays the Opportunity which have the Account. If any Opportunity don't have Account it'll not display.
Am i Correct..?
=======>Doubt:So, is it possible to display all Opprtunity records even though they don't have the Account. If so......How?
Hi Ravi,
Speaking as per salesforce CRM the independent opportunity doesnot make any sense.
If you want to include them as well you may need to modify the controller code to be like.
Please mark this as solution if this solves your problem, So that if anyone has this issue this can help.
Do you know ?
How values automatic display on same page when i selected checkbox values and then i click on Done button, the selected value display on ckEditor body which is parent page ? How is it possible ?
Thanks.