3

I have the following Controller and Component working together. My issue is that the acctWrapList isn't displaying to the page. I put in some debug logs and it's showing the account data in the logs but it's not getting displayed to the page itself. I've tried many sources but I'm still not able to display the accounts listed from the query results to the page.

My controller:

   private void runQuery() {
    //init wrapper class
    acctWrapList = new List<accountWrap>();
    try {
        system.debug(accounts);
        accounts = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 10');
        //Adds search results to wrapper class
        for(Account a: accounts){
            acctWrapList.add(new accountWrap(a,false));
        }
    } 
    catch (Exception e) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
        System.debug('Error ' + e);
    }
}
public void runQueryLoad(string c) {
    soql2 = 'select Id, Owner.Id, Parent.Id, Parent.Name, Name, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, Street_Address__c, City__c, State_Province__c, Zip_Postal_Code__c, Country_Code__c, Account_Intergraph_Line_of_Business__c, Industry, Type, Phone, Account_Category__c, RecordTypeId from account where name =: company';  
    if(c != null){
        company = c;
        system.debug(company);
        //init wrapper class
        acctWrapList = new List<accountWrap>();
        try {
            system.debug(accounts);
            accounts = Database.query(soql2 + ' order by ' + sortField + ' ' + sortDir + ' limit 10');
            //Adds search results to wrapper class
            if(!accounts.isEmpty()){
                for(Account a: accounts){
                    acctWrapList.add(new accountWrap(a,false));
                    system.debug(a);
                }
            }
            else if(accounts.isEmpty()){
                soql = 'select Id, Owner.Id, Parent.Id, Parent.Name, Name, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, Street_Address__c, City__c, State_Province__c, Zip_Postal_Code__c, Country_Code__c, Account_Intergraph_Line_of_Business__c, Industry, Type, Phone, Account_Category__c, RecordTypeId from account where name != null';  
                runQuery();
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'No possible matching Accounts were found. Please use the search parameters to find an account. '));
            }
        }
        catch (Exception e) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
            System.debug('Error ' + e);
        }
    }
}

Visualforce Component:

    <td valign="top" width="775">

<apex:pageBlock mode="edit" id="resultsA">
    <apex:actionSupport event="onclick"  reRender="resultsA" status="actionStatus"/>
    <apex:actionStatus id="actionStatus" startText="Loading..." stopText="" />
    <apex:pageBlockTable value="{!acctWrapList}" var="acctWrap" align="top" >
        <apex:column >
            <apex:inputCheckbox id="selectAccountRow" value="{!acctWrap.isSelected}" onselect="toggle(this)">
               <apex:actionSupport event="onclick" action="{!selectAcct}" reRender="SCOutputPanel, accountFieldPanel, convertLeadPanel" /> 
            </apex:inputCheckbox>
        </apex:column>
        <apex:column >
            <apex:facet name="header">
                <apex:commandLink value="Account" action="{!toggleSort}" rerender="resultsA,debug" >
                    <apex:param name="sortField" value="Name" assignTo="{!sortField}"/>
                </apex:commandLink>
            </apex:facet>
                <a href="/{!acctWrap.oAccount.Id}"
                   id="{!acctWrap.oAccount.Id}"
                   target= "_blank"
                   onblur="LookupHoverDetail.getHover('{!acctWrap.oAccount.Id}').hide();" 
                   onfocus="LookupHoverDetail.getHover('{!acctWrap.oAccount.Id}', '/{!acctWrap.oAccount.Id}/m?retURL=%2F{!acctWrap.oAccount.Id}&isAjaxRequest=1').show();" 
                   onmouseout="LookupHoverDetail.getHover('{!acctWrap.oAccount.Id}').hide();" 
                   onmouseover="LookupHoverDetail.getHover('{!acctWrap.oAccount.Id}', '/{!acctWrap.oAccount.Id}/m?retURL=%2F{!acctWrap.oAccount.Id}&isAjaxRequest=1').show();">
                   {!acctWrap.oAccount.Name}
                </a>
        </apex:column>
        <apex:column >
            <apex:facet name="header">
                <apex:commandLink value="Country" action="{!toggleSort}" rerender="resultsA,debug">
                    <apex:param name="sortField" value="Country_Code__c" assignTo="{!sortField}"/>
                </apex:commandLink>
            </apex:facet>
            <apex:outputField value="{!acctWrap.oAccount.Country_Code__c}"/>
        </apex:column>
        <apex:column >
            <apex:facet name="header">
                <apex:commandLink value="Industry" action="{!toggleSort}" rerender="resultsA,debug">
                    <apex:param name="sortField" value="industry" assignTo="{!sortField}"/>
                </apex:commandLink>
            </apex:facet>
            <apex:outputField value="{!acctWrap.oAccount.industry}"/>
        </apex:column>

        <apex:column >
            <apex:facet name="header">
                <apex:commandLink value="Parent Account" action="{!toggleSort}" rerender="resultsA,debug">
                    <apex:param name="sortField" value="parent.name" assignTo="{!sortField}"/>
                </apex:commandLink>
            </apex:facet>
            <apex:outputField value="{!acctWrap.oAccount.parent.name}"/>
        </apex:column>
    </apex:pageBlockTable>
</apex:pageBlock>
</td>

Wrapper Class:

// the soql without the order and limit
private String soql {get;set;}
// the soql that searches for existing account with lead name
private String soql2 {get; set;}
// the collection of contacts to display
public List<Account> accounts {get;set;}
//WrapperClass list for accounts searched
public List<accountWrap> acctWrapList {get; set;}
private String company;

//Wrapper Class set up and defined - used for the page 
public class accountWrap{
    public account oAccount{get;set;}
    public boolean isSelected{get;set;}
    public accountWrap(account a, boolean b){
        this.oAccount=a;
        this.isSelected=b;
    }
}
//Checkbox action for selecting Account from the search results in the page
public void selectAcct(){
    boolean checked = false;
    for (accountWrap aWrapper : acctWrapList){
        if (aWrapper.isSelected){
            checked = true;
            system.debug('AccountWrapper '+ aWrapper.oAccount.Id);
            theAccount.acctData = aWrapper.oAccount;
            system.debug('AccountSearch '+ theAccount.acctData);
            system.debug(aWrapper.isSelected);
            system.debug(theAccount);
        }
    }
    if (!checked){
        theAccount.acctData = null;
    }
}
public void toggleCheck(){
    boolean checked = false;
    for (accountWrap aWrapper : acctWrapList){
        if (aWrapper.isSelected){
            checked = true;
            aWrapper.isSelected = true;
        }
    }
6
  • Can you please add the wrapper class code + the definition of the wrapper list at the top of your class Apr 27, 2015 at 18:08
  • I added the wrapper class and most of the definitions for the class. Hope it helps! Thanks Apr 27, 2015 at 18:24
  • 1
    I can't seen any issues. I think your next step should be attempting to simplify the vf page - put in a simple <apex:repeat> tag and display one or two elements from this wrapper inside a standard html table. Then you'll know it's getting to the vf page successfully. Apr 27, 2015 at 18:29
  • Sorry I'm not familiar with the repeat tag, can you show me where to put it? Thanks! Apr 27, 2015 at 19:24
  • I'll add the code as an answer... Apr 27, 2015 at 19:26

1 Answer 1

1

There is a lot of code to debug here, but probably the best thing you can do right now is to simplify. To do this, you can use a repeat tag and put a subset of your data in it to make sure the data is getting to the page correctly.

Then you can build up the rest of your page slowly and eliminate the error.

Your a simplified version of your table using a repeat would look like this:

<table class="">
    <col style="width: 25%;"/>
    <col style="width: 25%;"/>
    <col style="width: 25%;"/>
    <col style="width: 25%;"/>
    <apex:repeat value="{!acctWrapList}" var="acctWrap">
    <tr >
      <td >{!acctWrap.isSelected} </td>
      <td >{!acctWrap.oAccount.Id}</td>
      <td >{!acctWrap.oAccount.Country_Code__c}</td>
      <td >{!acctWrap.oAccount.industry}</a>
      </td>
    </tr>
    </apex:repeat>
</table>

You have a very complicated page to debug, so unfortunately, it's going to be hard to debug it - but starting small and adding to it is definitely a good strategy.

You must log in to answer this question.

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