0

I am trying to return a wrapper class containing two properties and a list. I have a method getTables which is populating a wrapper, and the issue I am running into is when calling them. I have tried various variations of accessing the populated wrapper DTO TableData in the return statement. I am using another method in a similar way to populate other fields though not needing wrapper. So I wanted to know if is possible to do something similar i.e. value ={!getMethod.Field__c} with a wrapper class in nested repeats. I have tried

first.TableData.AccountNumber
first.AccountNumber
first.TableData.RowData.FinServ__FinancialAccount__r.FinServ__FinancialAccountNumber__c
first.FinServ__FinancialAccountNumber__c

But there is an issue with binding, and when I use the TableData, either in the <apex:outputfield value or in <apex:repeat value="{!Tables.TableData}" reference, it becomes unknown. So I am not sure how to reference the populated values.

<div>    
    <apex:repeat value="{!Tables}" var="first">
        <table id="tableOne">
            <thead id="tHead" style="border-bottom: 2px solid black;">
                 <tr>
                    <th></th>
                    <th>Acct # &nbsp; <apex:outputField value="{!first.AccountNumber}"/></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                </tr>              
            </thead>
            <apex:repeat value="{!first}" var="second" >
                <tbody id="tBody">                              
                    <tr>      
                        <td><apex:outputField value="{!second.TableData.Name}"/></td>
                        <td></td> 
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>            
                    </tr>  
                </tbody>
            </apex:repeat>      
        </table>     
    </apex:repeat> 
</div>
public class DataWrapper {
  public String AccountNumber { get; set; }
  public String Custodian { get; set; }       
  public List<FinServ__FinancialHolding__c> RowData = new List<FinServ__FinancialHolding__c>();
}

public List<DataWrapper> getTables() {

...

List<DataWrapper> TableData = new List<DataWrapper>();

for(FinServ__FinancialHolding__c row: [SELECT FinServ__FinancialAccount__r.Name, FinServ__FinancialAccount__r.Custodian__c,   
                                                        FinServ__FinancialAccount__r.Date_Validated__c, FinServ__FinancialAccount__r.FinServ__FinancialAccountNumber__c, 

FinServ__Symbol__c, FinServ__Shares__c, FinServ__Price__c, FinServ__MarketValue__c
FROM FinServ__FinancialHolding__c
WHERE FinServ__FinancialAccount__r.FinServ__PrimaryOwner__c = :ApexPages.currentPage().getParameters().get('id') AND   
                                                  FinServ__FinancialAccount__r.FinServ__FinancialAccountNumber__c = :strNum]) 
{     
  DataWrapper dto = new DataWrapper();
                  
  dto.AccountNumber = row.FinServ__FinancialAccount__r.FinServ__FinancialAccountNumber__c;               
  dto.Custodian = row.FinServ__FinancialAccount__r.Custodian__c;
  dto.RowData.add(row);
                   
  TableData.add(dto);
 }

...

}

Thanks for any help

EDITS

Due to the nested repeat in Visualforce page not being able to access the RowData property I had to change the wrapper and add a constructor and change RowData from a list of lists to a get set property. That has been able to solve the 'Unkonwn Property' error when trying to access the lists in the second repeat.

  public List<FinServ__FinancialHolding__c> RowData  { get; set; } 

  public DataWrapper(){
            RowData = new List<FinServ__FinancialHolding__c>();
        }

1 Answer 1

0

TableData is a local variable, not something you'd reference in your markup. Assuming the method is getTables(), such that {!tables} returns TableData, you'd have a wrapper with three properties. That might look something like:

<apex:repeat value="{!Tables}" var="first">
    <table id="tableOne">
        <thead id="tHead" style="border-bottom: 2px solid black;">
             <tr>
                <th></th>
                <th>Acct # &nbsp; <apex:outputField value="{!first.AccountNumber}"/></th>
                <th></th>
                <th></th>
                <th></th>
                <th></th>
            </tr>              
        </thead>
        <apex:repeat value="{!first.RowData}" var="second" >
            <tbody id="tBody">                              
                <tr>      
                    <td><apex:outputField value="{!second.Name}"/></td>
                    <td></td> 
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>            
                </tr>  
            </tbody>
        </apex:repeat>      
    </table>     
</apex:repeat> 
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .