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
Pratap adminPratap admin 

Switching the visualforce tabs dynamically

In my current application, there is text field named item, clicking on popup icon for this field, one Visualforce page with 2 Tabs opens.
first Tab:         visualforce page that contains data from recent items custom object  (using apex:Include under apex:tab)
second page : visualforce page that containss data from All Items custom object (using apex:Include under apex:tab)

By default, i have made the first page as active, but my requirement is that when there is no data in first page, second tab should become active.
I am not getting how can i dynamically set the second page as active.
Pratap adminPratap admin
<apex:page showHeader="false" tabStyle="account" >
    <apex:tabPanel switchType="client" selectedTab="Recent Items"
    id="AccountTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab">
        <apex:tab label="Recent Items" name="Recent Items " id="tabRecentProduct">
             <apex:include pageName="Vfpage1"/> ===>page one with controller1 class
        <apex:tab label="All Items" name="All Items" id="tabAllItems">
             <apex:include pageName="Vfpage2/>  ===> page two with controller2 class
        .activeTab {
            background-color: #236FBD;
        .inactiveTab { 
               background-color: lightgrey;

By default vfpage 1 is active but when there is no data fetched from controller1, vfpage2 should be shown..
So how can it be set dynmiclly.can we chnge the "selectedTab" attribute in vfpage1?