+ Start a Discussion
wsuycottwsuycott 

Trying to get actionSupport when a tab comes into focus

Have a tabbed account setup that loads numerous custom related lists - and this of course impacts load-time performance significantly (open opportunities list, closed opportunities list, our assets, competitors assets, etc.).  These are each located within their own tabpanels, then their own tab, and finally a form with VF to display.  The current controller loads all lists when the VF page loads - so I am frequently waiting for 15-20+ seconds for the page to display.

 

In trying to reduce initial load times I am trying to find a means of only loading the list and rendering the form when the user selects the tabPanel or when the individual tab beneath the panel, or the form beneath the tab comes into focus.  So far, numerous attempts to have the actionSupport action fire are not working.  The action method isn't getting called. 

 

Any ideas on where I have gone wrong?

<apex:tab label="Contacts" name="Contacts" id="tabContacts"> <apex:tabPanel switchType="client" id="tTbPnlCont" > <apex:tab label="Contact" name="Contact" id="tabContact"> <apex:form id="actConForm" > <apex:actionSupport event="onfocus" focus="actConForm" action="{!loadActiveContacts}" rerender="actConForm" status="actconstat"/> <apex:actionStatus id="actconstat" startText="Retrieving contacts" stopText=""/> <apex:pageblock id="ActContacts" title="Active Contacts" > <apex:pageBlockButtons > <apex:pageBlockTable id="ActCont" value="{!ActiveContact}" var="o" rendered="{!IF(activeContactFlag=True,true,false)}"> The Controller action method excerpt List<Contact> ActiveContact = null; Private Boolean activeContactFlag = False; public boolean getactiveContactFlag() { return activeContactFlag; } // // loadActiveContacts does not get executed per debug log // public PageReference loadActiveContacts() { system.debug('DEBUG: getActiveContacts called'); List<Contact> con = getActiveContact(); return null; } // // The code below works fine when referenced in VF pageBlockTable // without the render="{!IF(activeContactFlag=True,true,false)}" // public List<Contact> getActiveContact() { if(ActiveContact == null) { sortExpression = 'name'; sorterActiveContacts.originalList = [Select LastName,FirstName,email from Contact where AccountId = :acct.id and Inactive_contact__c = False ORDER BY LastName,FirstName LIMIT 1000]; ActiveContact = (List<Contact>) sorterActiveContacts.getSortedList(sortExpression, sortAscending); activeContactFlag = True; } return ActiveContact; }

 

TH53TH53

Did you ever get this to work properly?