Call controller method from tab component

How to call controller method from tab component in visualforce?


public with sharing class tabController2 {
    public list<account> accList {get; set;}
    public list<contact> conList {get; set;}
    public tabController2(){
        accList = [select name from account where industry = 'energy'];    
    public void contactRec(){
        conList = [select lastName from contact];



<apex:page controller="tabController2">
        // jsFunc is called from tab2 (referred by id in apex:tab) 
         function jsFunc(){

     <apex:form >
         <apex:tabPanel id="tabP"  switchType="ajax">
             <apex:tab label="Energy Accounts">             
                 <apex:pageblock >
                    <apex:pageblockTable value="{!accList}" var="a">
                        <apex:column value="{!}"/>
             <apex:tab label="Contact Records" oncomplete="jsFunc()" id="tab2">
                  <apex:pageblock >
                    <apex:pageblockTable value="{!conList}" var="c">
                        <apex:column value="{!c.lastName}"/>
         <!-- Once the actionfun is invoked from javascript and contactRec will be invoked -->
         <apex:actionFunction name="actionfun" action="{!contactRec}" reRender="tabP"/>


Related posts

Leave a Comment