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
Amoolya DontyAmoolya Donty 

call methods for each tab in apex:tab

Hi, 
I need to call different methods for each tab. How i need to achieve that?

I used onClick in apex:tabPanel but tab is getting changed if i click within tab area.

onTabEnter is also not working for me in apex:tab.


Thanks in advance
Darshan Shah2Darshan Shah2
Hi Amoolya Donty,

I have written piece of code,
Kindly let me know whether its suffice your problem.

Class:
public class ApexTabController
{
    public Boolean isTab1 {get;set;}
    public Boolean isTab2 {get;set;}
    
    public void function1()
    {
        isTab1 = true;
        isTab2 = false;
    }
    public void function2()
    {
        isTab1 = false;
        isTab2 = true;
    }
}

Page:
<apex:page id="thePage" controller="ApexTabController">
    <apex:form>
        <apex:tabPanel switchType="client" id="theTabPanel" >
            <apex:tab label="One" name="name1" id="tabOne" onTabEnter="tab1()" />
            <apex:tab label="Two" name="name2" id="tabTwo" onTabEnter="tab2()" />
        </apex:tabPanel>
        <apex:outputPanel id="opTab">
            <apex:outputText>isTab1 = {!isTab1} , isTab2={!isTab2}</apex:outputText>
        </apex:outputPanel>
    <apex:actionFunction action="{!function1}" name="tab1" reRender="opTab"/>
    <apex:actionFunction action="{!function2}" name="tab2" reRender="opTab"/>
    </apex:form>
</apex:page>


Warm Regards,
Darshan Shah