+ Start a Discussion
OldDeadBugOldDeadBug 

<apex:repeat> displaying duplicate values??

So, I have a list of Territories associated with Accounts.

 

The list has only two Territories, and I want to list their names in a pageBlockTable.

 

I am cycling through a list of AccountUIElements - a class I created to be able to store Territories with their associated Accounts so I could iterate through one list and reference both objects.

 

system.debug statements already confirm that there are only two Territory values in the AccountUIElement's 'AccTerrs' territory list = one for 'Western 5', another for 'Inside 1'. The page has the following code:

 

<apex:pageBlockTable value="{!UIAccts}" var="UIA" columns="6" columnswidth="10,10,15,35,10,10">

...other columns which display correctly...

<apex:column headervalue="Current Territories" id="AccTerrs" > <apex:panelgrid columns="1"> <apex:repeat value="{!UIA.AccTerrs}" var="terr"> <apex:outputText value="{!terr.Name} " /> </apex:repeat> <apex:panelgrid> <apex:column>

</apex:pageBlockTable>

The page displays this column as 'Western 5 Inside 1 Western 5 Inside 1'. Again the AccTerrs list only has the two Territories, and the process only appears to be running once according to the debug log (otherwise the other columns would be displaying with duplicate values??).

 

Any ideas on why this is happening, and how I can prevent it???

 

Thanks

 

ODB

S_LieS_Lie
Can you post the class ?
OldDeadBugOldDeadBug

Sure

 

This is the AccountUIElement class.

public class AccountUIElement { public boolean selection; private set<id> TIds = new set<id>{}; public Territory[] AccTerrs = new Territory[]{}; public Account Acc; public Account getAcc() { return acc; } public void setAcc(Account A) { Acc = A; } public Territory[] getAccTerrs() { return AccTerrs; } public void setAccTerrs(Territory T) { if (AccTerrs.isEmpty()) { AccTerrs.add(T); TIds.add(T.id); } else { for (id oldT :TIDs) if (oldT != T.id) { AccTerrs.add(T); TIds.add(T.id); } } } public boolean getSelection() { return Selection; } public void setSelection(boolean S) { Selection = S; } }

 

The Territories are queried in the controller by querying the associated AccountShares, then the associated Groups, and finally the Territories.

OldDeadBugOldDeadBug

Found it!!

 

I was loading the AccountUIElement class lists with duplicate data in another part of the code.

 

Thanks anyway

 

ODB