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
bluecapbluecap 

Issue displaying lookup inputField through wrapper class results

Im having trouble getting the Financial_Account__c lookup field to display properly on my visualforce page. I am loading a wrapper class that contains Financial_Account_c and Holding_c. The Holding__c object has a lookup on it to Financial_Account_c. Im unable to get the field to display like it should as an inputField through Holding_c.Financial_Account__c nor directly to Financial_Account__c. All suggestions are appreciated.

Controller

public class ctrl {

    public list<holdingsWrapper> holdingList {get;set;}
    public list<Holding__c> holdingResults {get;set;}

    public ctrl(){
        this.init();
    }

    private void init(){

        holdingList = new list<holdingsWrapper>();
        User advisorRec = new User();

        String mhQuery = 'SELECT Name, ';
        mhQuery += 'Financial_Account__c, ';
        mhQuery += 'Advisor_ID__c ';
        mhQuery += 'FROM Holding__c ';

        holdingResults = Database.query(mhQuery);

        for(Holding__c m : holdingResults)
        {
            holdingList.add(new holdingsWrapper(m.Financial_Account__r, m));
        }

    }

    public class holdingsWrapper
    {
        public Financial_Account__c fa {get; set;}
        public Holding__c maho {get; set;}

        public holdingsWrapper(Financial_Account__c a, Holding__c mh)
        {
            fa = a;
            maho = mh;
        }
    }

}

Visualforce Page
 
<apex:page controller="ctrl" title="Financial Accounts" sidebar="false">

<apex:form id="myMHForm">
    <apex:outputPanel id="formPanel" layout="inline">

        <apex:pageBlock title="Financial Accounts" id="muselectedlist">

            <apex:pageBlockTable value="{!mhList}" var="mhItem" id="pgTable1">

                <apex:column headerValue="Financial Account" id="movetoaccount">
                    <apex:inputField value="{!mhItem.fa}" />
                    <!-- <apex:inputField value="{!mhItem.maho.Financial_Account__c}" /> -->
                </apex:column>
            </apex:pageBlockTable>

        </apex:pageBlock>

    </apex:outputPanel>
    </apex:form>

</apex:page>

ISSUE 1: The following does not allow me to save my VF page:
 
<apex:inputField value="{!mhItem.fa}" />
 
ERROR: Save error: Could not resolve the entity from value binding '{!mhItem.fa}'. can only be used with SObjects, or objects that are Visualforce field component resolvable. line 0 Force.com save problem

ISSUE 2: The following version saves, but only displays text and NOT the input field with the magnify glass:
 
<apex:inputField value="{!mhItem.maho.Financial_Account__c}" />

How do I get the field to display properly?

All suggestions are appreciated!
bluecapbluecap
Correction:

<apex:pageBlockTable value="{!mhList}" var="mhItem" id="pgTable1">

Should be:

<apex:pageBlockTable value="{!holdingList}" var="mhItem" id="pgTable1">