1

I'm having problems with getting my data to display on my visualforce page. The logs show data inside the variable, but when I try to display the data in a table nothing shows but the headers. Thanks in Advance.

Controller: public with sharing class RelationshipManagerAccountUtils {

private ApexPages.StandardController controller {get; set;}
public List<Relationship_Manager_Accounts__c> searchResults {get; set;}
public string searchText {get; set;}

public RelationshipManagerAccountUtils(ApexPages.StandardController controller) {}

public PageReference search() {
    String qry = 'SELECT Id, Account__r.name,Account__r.id, Recruiter__r.name, RM_Rank__c, Relationship_Manager_Contact__r.name FROM Relationship_Manager_Accounts__c '+'WHERE Account__r.name LIKE \'%' +searchText+'%\' ORDER BY Account__r.name';
    searchResults = Database.query(qry);
    System.debug(searchResults);
    return null;
}
public PageReference save() {

    try {
        update searchResults;
    } catch(DMLException e) {
        ApexPages.addMessages(e);
        return null;
    }

    return new PageReference('/' +ApexPages.currentPage().getParameters().get('id'));
}

public PageReference cancel() {
    return new PageReference('/' +ApexPages.currentPage().getParameters().get('id'));
}

}

<b>Visualforce Page:</b>
<apex:page standardController="Relationship_Manager_Accounts__c" extensions="RelationshipManagerAccountUtils">
    <apex:sectionHeader title="Relationship Manager Account" subtitle="{!Relationship_Manager_Accounts__c.Account__r.name}"/>
    <b>Hello {!$User.FirstName}! Welcome to the RM Accounts Page.</b>
    <apex:form >
    <apex:pageBlock title="RM Account Search" mode="edit">
    <apex:pageMessages />
        <apex:pageBlockButtons location="both">
            <apex:commandButton action="{!save}" value="Save Records"/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem >
                <apex:outputLabel for="searchText">Account</apex:outputLabel>               
                <apex:panelGroup >
                <apex:inputText id="searchText" value="{!searchText}"/>
                <apex:commandButton value="Search" action="{!search}" rerender="block" status="status"/>
                </apex:panelGroup>               
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection><br/>
        <apex:actionStatus id="status" startText="Searching... please wait..."/>
        <apex:pageBlockSection title="Search Results" id="resultsBlock" columns="1">
            <apex:pageBlockTable value="{!searchResults}" var="accts" >
                <apex:column value="{!accts.Account__r.name}" headerValue="ISO Account"/>
                <apex:column value="{!accts.Relationship_Manager_Contact__r.name}" headerValue="Relationship Manager"/>
                <apex:column value="{!accts.RM_Rank__c}" headerValue="RM Rank"/>
                <apex:column value="{!accts.Recruiter__r.name}" headerValue="Recruiter"/>               
            </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
    <apex:pageBlock title="Relationship Manager Account">
    <apex:pageMessages />
        <apex:pageBlockSection title="Information" columns="2"> 
            <apex:outputField title="Relationship Manager" label="Relationship Manager" value="{!Relationship_Manager_Accounts__c.Relationship_Manager_Contact__r.name}" />
            <apex:outputField title="RM Rank" value="{!Relationship_Manager_Accounts__c.RM_Rank__c}" />
            <apex:outputField title="Recruiter" value="{!Relationship_Manager_Accounts__c.Recruiter__r.name}" />
            <apex:outputField title="Account" value="{!Relationship_Manager_Accounts__c.Account__r.name}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

I know there is a redundant page block at the bottom as I was just trying things out and it wasn't hurting anything.

2

Looks like your problem is that your search button rerenders something called "block" but your results appears to be in a block called "resultsBlock". Try updating your button to rerender the "resultsBlock" instead.

  • Thank you so much! I couldn't figure it out for the life of me. That totally makes sense now. – nwillard Apr 25 '15 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.