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
VisualForceVisualForce 

How to find which tab is clicked?

Hi..

  I am using <apex:tabpanel> for displaying tabs One & Two.. I want to know which tab is selected

<apex:page id="thePage"> <apex:outputtext> Here I have to display some content based on tab selection </apex:outputtext> <apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel"> <apex:tab label="One" name="A" id="tabOne">content for tab one</apex:tab> <apex:tab label="Two" name="B" id="tabTwo">content for tab two</apex:tab> </apex:tabPanel> </apex:page>

Based on the tab selection I have to do some calculation and display some content... If tab One is selected I have to display Tab One is selected like that..

 

 

Is it possible in VF..?

Venkat PolisettVenkat Polisett

<apex:tab label="One" name="A" id="tabOne" onClick="alert('You clicked on tab ONE');">content for tab one</apex:tab>


VisualForce wrote:

Hi..

  I am using <apex:tabpanel> for displaying tabs One & Two.. I want to know which tab is selected

<apex:page id="thePage"> <apex:outputtext> Here I have to display some content based on tab selection </apex:outputtext> <apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel"> <apex:tab label="One" name="A" id="tabOne">content for tab one</apex:tab> <apex:tab label="Two" name="B" id="tabTwo">content for tab two</apex:tab> </apex:tabPanel> </apex:page>

Based on the tab selection I have to do some calculation and display some content... If tab One is selected I have to display Tab One is selected like that..

 

 

Is it possible in VF..?


 

Ron HessRon Hess

I believe that you want the value="{!selectedTab}"  in the  apex : tab component

 

 

value

 

The current active tab. You can specify this with an expression to dynamically control the active tab. For example, value="{!TabInFocus}", where TabInFocus is a variable set by a custom controller.

VisualForceVisualForce

Thanks for ur reply Ron & Venkat

 

Venkat:

 

    " I have to do some calculation based on tab selection" -- Ur code just alert some message..

 

Ron:

 

     There is no value attribute in tab component...  What is the use of value attribute in tabpanel Component...

Still I am in starting position ..

 

 

Ron HessRon Hess


What is the use of value attribute in tabpanel Component...

 

 


it specifies which panel to draw, and which was clicked on,bind this to a string in your controller, with a getter and setter, throw in a debug statement as well.

 

or check the docs on this component.

JavajJavaj

here is the answer with sample code:

 

 

Code:
public class Tabs {
public String SelectedTab { get; set; }
}

Code:
<apex:page controller="Tabs" >
<apex:tabPanel switchType="Ajax" value="{!SelectedTab}">
<apex:tab label="Tab1" name="Name1" />
<apex:tab label="Tab2" name="Name2" />
<apex:tab label="Tab3" name="Name3" />
<apex:tab label="Tab4" name="Name4" />
</apex:tabPanel>
{!SelectedTab}
</apex:page>

 
Cheers,
Saravanan
Message Edited by Javaj on 08-04-2009 11:35 AM
Prashant Sontakke 12Prashant Sontakke 12
javaj
This solution wont work, as it reloads the complete page and how to achieve this functionality withut reloading the complete page, just like switch type as client. I'm also in need of same solution