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
hisrinuhisrinu 

Problem with Repeat Tag - Urgent

Hi,

 

I am trying to display Parent and child records using repeat tag.

I don't know what is the problem with the following code, it is not showing any error in the same way it is not giving the desired output.

 

Can anyone point me to the right direction.

 

 

<apex:repeat value="{!PDFList}" var="p"> <apex:pageblockSection title="{!p.ol.Name}" columns="1"> <apex:repeat value="{!p.APB}" var="a1"> <apex:pageBlock title="TEST"></apex:pageBlock> <apex:outputText value="{!a1.Id}"/> </apex:repeat> <apex:repeat> my Wrapper Class is Public class Order_PDF { Public class pdfclass { Public Order_Line_Item__c Ol{get; set;} Public List<Access_Port_Backup__c> APB{get; set;} public pdfclass(Order_Line_Item__c O, List<Access_Port_Backup__c> A) { ol = o; APB = a; } } }

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess

Two things jump out, it looks like you are clearing each and every list,

so i can see how no data will be drawn on the page.

 

Basically you create a list pass that list into a class to hold it, then delete that list.

The class does not make a copy of the data that is passed into it.  Your class may want to clone() the list.

 

also, you cannot remove items from a list in Apex while you are iterating over that list. 

This is documented in the apex code docs under list manipulation.

All Answers

Ron HessRon Hess
it looks correct , are you sure you are initializing each element of PDFClass with valid data ?
hisrinuhisrinu

Thanks for your reply Ron, I am intializing each element of PDFClass.

 

Here I am posting entire code, pls have a look.

One more problem is I am getting an error like "Already Output".

 

<apex:page standardController="Order_Header__c" extensions="Order_PDF">
<apex:form >
<apex:pageBlock >
<apex:commandButton action="{!Pdf}" value="Get PDF"/>
<apex:repeat value="{!PDFList}" var="p">
<apex:pageblockSection title="{!p.ol.Name}" columns="1">
<apex:repeat value="{!p.APB}" var="a1">
<apex:pageBlock title="TEST"></apex:pageBlock>
<apex:outputText value="{!a1.Id}"/>
</apex:repeat>
<apex:repeat value="{!p.CD}" var="a2">
<apex:pageBlock title="TEST"></apex:pageBlock>
<apex:outputText value="{!a2.Name}"/>
</apex:repeat>
<apex:repeat value="{!p.CS}" var="a3">
<apex:pageBlock title="TEST"></apex:pageBlock>
<apex:outputText value="{!a3.Name}"/>
</apex:repeat>
<apex:repeat value="{!p.EI}" var="a4">
<apex:pageBlock title="TEST"></apex:pageBlock>
<apex:outputText value="{!a4.Name}"/>
</apex:repeat>
<apex:repeat value="{!p.Feature}" var="a5">
<apex:pageBlock title="TEST"></apex:pageBlock>
<apex:outputText value="{!a5.Name}"/>
</apex:repeat>
<apex:repeat value="{!p.NB}" var="a6">
<apex:pageBlock title="TEST"></apex:pageBlock>
<apex:outputText value="{!a6.Name}"/>
</apex:repeat>
<apex:repeat value="{!p.RRC}" var="a7">
<apex:pageBlock title="TEST"></apex:pageBlock>
<apex:outputText value="{!a7.Name}"/>
</apex:repeat>
<apex:repeat value="{!p.TD}" var="a8">
<apex:pageBlock title="TEST"></apex:pageBlock>
<apex:outputText value="{!a8.Name}"/>
</apex:repeat>
</apex:pageblockSection>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Public class Order_PDF
{
public Order_PDF(ApexPages.StandardController controller)
{
}

Billing_Account_Order_Use__c BAOU;
List<Order_Line_Item__c> orderLineItems = new List<Order_Line_Item__c>();
List<Access_Port_Backup__c> APBList = new List<Access_Port_Backup__c>();
List<Circuit_Details__c> CDList = new List<Circuit_Details__c>();
List<CoS_Segment__c> CSList = new List<CoS_Segment__c>();
List<EVC_Information__c> EIList = new List<EVC_Information__c>();
List<Features__c> FeatureList = new List<Features__c>();
List<Network_Based__c> NBList = new List<Network_Based__c>();
List<Router_RouterCards__c> RRCList = new List<Router_RouterCards__c>();
List<Technical_Details__c> TDList = new List<Technical_Details__c>();
List<Billing_Account_Order_Use__c> BAOUList = new List<Billing_Account_Order_Use__c>();
List<Id> idList = new List<Id>();

List<Access_Port_Backup__c> newAPBList = new List<Access_Port_Backup__c>();
List<Circuit_Details__c> newCDList = new List<Circuit_Details__c>();
List<CoS_Segment__c> newCSList = new List<CoS_Segment__c>();
List<EVC_Information__c> newEIList = new List<EVC_Information__c>();
List<Features__c> newFeatureList = new List<Features__c>();
List<Network_Based__c> newNBList = new List<Network_Based__c>();
List<Router_RouterCards__c> newRRCList = new List<Router_RouterCards__c>();
List<Technical_Details__c> newTDList = new List<Technical_Details__c>();
List<pdfclass> PDFList = new List<pdfclass>();

Public PageReference Pdf()
{
Id ordId = System.currentPageReference().getParameters().get('id');
//BAOU = [select Name,Billing_Account__c,Billing_Account__r.Name,Billing_Account__r.Billing_Account__c,Site_Name__r.Name,Order_Number__r.Name from Billing_Account_Order_Use__c where Order_Number__c=:ordId];
orderLineItems = [Select VLAN_DLCI__c, Access_Method__c, ATQ_Reference__c from Order_Line_Item__c where Order_Number__c = :ordId];
for(Order_Line_Item__c oli:orderLineItems)
idList.add(oli.id);

APBList = [Select Unit_Discount_Monthly_Rent__c, Backup_Access_Type__c, Access_Type__c from Access_Port_Backup__c where Order_Line_Item__c in :idList];


CDList = [Select Total_Monthly_Rental_Charge__c, Access_Type__c from Circuit_Details__c where Order_Line_Item__c in :idList];

CSList = [Select Unit_Discount_Monthly_Rent__c, Configuration_Type_BackUp__c from CoS_Segment__c where Order_Line_Item__c in :idList];
EIList = [Select VLAN_Identifier_on_which__c, Amortisation_Period__c from EVC_Information__c where Order_Line_Item__c in :idList];


FeatureList = [Select Unit_Discount_Monthly_Rent__c, CreatedById from Features__c where Order_Line_Item__c in :idList];


NBList = [Select Unit_Discount_Monthly_Rent__c, CreatedById from Network_Based__c where Order_Line_Item__c in :idList];
RRCList = [Select Unit_Discount_Monthly_Rental__c, Customer_Router__c from Router_RouterCards__c where Order_Line_Item__c in :idList];
TDList = [Select xDSL_line_type__c, UK_BT__c, Access_Resilience_Diversity_and_Separacy__c from Technical_Details__c where Order_Line_Item__c in :idList];

for(Order_Line_Item__c oli:orderLineItems)
{
for(Integer i=0; i<APBList.size(); i++)
if(APBList[i].Order_Line_Item__c == oli.id)
{
newAPBList.add(APBList[i]);
APBList.remove(i);
}
for(Integer i=0; i<CDList.size(); i++)
if(CDList[i].Order_Line_Item__c == oli.id)
{
newCDList.add(CDList[i]);
CDList.remove(i);
}
for(Integer i=0; i<CSList.size(); i++)
if(CSList[i].Order_Line_Item__c == oli.id)
{
newCSList.add(CSList[i]);
CSList.remove(i);
}
for(Integer i=0; i<EIList.size(); i++)
if(EIList[i].Order_Line_Item__c == oli.id)
{
newEIList.add(EIList[i]);
EIList.remove(i);
}
for(Integer i=0; i<FeatureList.size(); i++)
if(FeatureList[i].Order_Line_Item__c == oli.id)
{
newFeatureList.add(FeatureList[i]);
FeatureList.remove(i);
}
for(Integer i=0; i<NBList.size(); i++)
if(NBList[i].Order_Line_Item__c == oli.id)
{
newNBList.add(NBList[i]);
NBList.remove(i);
}
for(Integer i=0; i<RRCList.size(); i++)
if(RRCList[i].Order_Line_Item__c == oli.id)
{
newRRCList.add(RRCList[i]);
RRCList.remove(i);
}
for(Integer i=0; i<TDList.size(); i++)
if(TDList[i].Order_Line_Item__c == oli.id)
{
newTDList.add(TDList[i]);
TDList.remove(i);
}
PDFList.add(new pdfclass(oli, newAPBList, newCDList, newCSList, newEIList, newFeatureList, newNBList, newRRCList, newTDList));
newAPBList.clear();
newCDList.clear();
newCSList.clear();
newEIList.clear();
newFeatureList.clear();
newNBList.clear();
newRRCList.clear();
newTDList.clear();
}
return null;
}
Public List<pdfclass> getPDFList()
{
system.debug('PDFLIST::::::'+pdflist);
return PDFList;
}
Public class pdfclass
{
Public Order_Line_Item__c Ol{get; set;}
Public List<Access_Port_Backup__c> APB{get; set;}
Public List<Circuit_Details__c> CD{get; set;}
Public List<CoS_Segment__c> CS{get; set;}
Public List<EVC_Information__c> EI{get; set;}
Public List<Features__c> Feature{get; set;}
Public List<Network_Based__c> NB{get; set;}
Public List<Router_RouterCards__c> RRC{get; set;}
Public List<Technical_Details__c> TD{get; set;}
public pdfclass(Order_Line_Item__c O, List<Access_Port_Backup__c> A, List<Circuit_Details__c> C, List<Cos_Segment__c> Cos, List<EVC_Information__c> E, List<Features__c> F, List<Network_Based__c> N, List<Router_RouterCards__c> R, List<Technical_Details__c> T)
{
ol = o;
APB = a;
CD = c;
CS = cos;
EI = e;
Feature = f;
NB = n;
RRC = r;
TD = t;
}
}
}

 

 

 I feel like everything is correct, but I am missing some point, could you point me where I need to change.

 

Thanks in Advance.

 

Message Edited by hisrinu on 04-09-2009 01:38 PM
Ron HessRon Hess

Two things jump out, it looks like you are clearing each and every list,

so i can see how no data will be drawn on the page.

 

Basically you create a list pass that list into a class to hold it, then delete that list.

The class does not make a copy of the data that is passed into it.  Your class may want to clone() the list.

 

also, you cannot remove items from a list in Apex while you are iterating over that list. 

This is documented in the apex code docs under list manipulation.

This was selected as the best answer
hisrinuhisrinu
Ron thanks alot, your reply is awesome. I can remove from the list i.e not a problem but I should not delete those lists. Its really awesome............ Thanks once again
hisrinuhisrinu

Ron, one more help is needed.

If I am not deleting the data then I am getting the duplicates......

is there any work around?

Ron HessRon Hess

you can create a clone of each list inside the constructor , then put your clear.list() code back in.

 

look up clone() and cloneDeep()

hisrinuhisrinu

I hope you are correct, let me check it once.

Thanks for your quick response.