I have an inputfield in my form which is a lookup. When I select a record from the list of lookup records (clicking the small magnifying glass) I am reading the id of that record and querying the related fields in my controller.
This is the lookup inputfield
<apex:inputField value="{!account}" onchange="getAccountId(this);"/>
In my script
var getAccountId = function(e) {
var id = document.getElementById(e.id + '_lkid').value;
getRelatedAccountHolders(id);
}
<apex:actionFunction name="getRelatedAccountHolders" action="{!getRelatedAccountHolders}" rerender="accHolderTab">
<apex:param name="accId" value=""/>
</apex:actionFunction>
In my controller
public List<AccountHolder__c> accHolderList {get; set;}
public void getRelatedAccountHolders() {
Id accountId = ApexPages.currentPage().getParameters().get('accId');
accHolderList = [select name, age, email from AccountHolder__c where Account = :accountId];
}
Now in the form there is a tabPanel which is suppose to show the account holders. I am planning to populate the tabs using repeat, something like this
<apex:tabPanel id="accHolderTab">
<apex:repeat value="{!accHolderList}" var="accHolder">
<apex:tab label="lab" name="accHolder.Name">
<apex:outputPanel >
//display account holder info in elegant form
</apex:outputPanel>
</apex:tab>
</apex:repeat>
</apex:tabPanel>
I am getting the list of account holders in accHolderList but the tabPanel does not get rendered or populated (I see an empty space and no tabs or panel at all).
I think that the tabPanel is rendered before the query is made in the controller and since the accHolderList is null at that time, it does not render anything.
Am I doing this right? Is there any other way to render AccountHolder records onchange of the Account lookup inputfield?
Thanks.