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
naveen reddy 68naveen reddy 68 

tabpanel in visualforce page

I have created a visual force page  with two tabs for the same object fields.
when i click on the button it must go to second tabs.

Here is my code:

<apex:page standardController="product_Development__c" extensions="HistoryPageController">
<apex:form >

<apex:pageblock title="VF Page Tabs" >
<apex:tabPanel id="theTabPanel" value="{!tabOpt}" >
<apex:tab label="Basic Info">
<b>Name:</b><apex:inputField value="{!product_Development__c.name}"/><br/>
<b>closed Date:</b>
<apex:inputField value="{!product_Development__c.Policy_Name__c}"/>
<br/>
<b>Education Requirement:</b><apex:inputField value="{!product_Development__c.Policy_Name__c}"/><br/>
<apex:commandButton value="Go to Two" action="{!switch}" rerender="theTabPanel"/>
</apex:tab>
<apex:tab label="DetailPage">
<b>Apex:</b><apex:inputField value="{!product_Development__c.product_Id__c  }"/><br/>
<b>Max_Pay:</b>
<apex:inputField value="{!product_Development__c.product_Id__c}"/>
<br/>
<b>Min_Payt:</b><apex:inputField value="{!product_Development__c.product_Id__c}"/><br/>
</apex:tab>
</apex:tabPanel>
</apex:pageblock>
  </apex:form>

</apex:page>

apex class:
public class HistoryPageController
{
    public String tabOpt {get;set;}
    private ApexPages.StandardController controller;

    public HistoryPageController(ApexPages.StandardController controller)
    {
    this.controller = controller;
    }
      
    
    public void switch()
    {
        tabOpt = 'DetailPage';
    }
}
 here the button is created and it not switching the second  tab.
Please help me.
Best Answer chosen by naveen reddy 68
Sohan Raj GuptaSohan Raj Gupta
Hi Naveen,

You can use below code:
 
public class HistoryPageController
{
    public String tabOpt {get;set;}
    private ApexPages.StandardController controller;

    public HistoryPageController(ApexPages.StandardController controller)
    {
    this.controller = controller;
     selectedTab = 'tab1';
    }
      
   
    
    private string selectedtab;

  public boolean getistab1disabled() {
    return selectedTab <> 'tab1';
  }

  public boolean getistab2disabled() {
    return selectedTab <> 'tab2';
  }

  public void Previous() {
    selectedtab = 'tab1';
  }

  public void Next() {
    selectedtab = 'tab2';
  }

  public string getselectedtab() {
     return selectedtab;
  }
}
 
<apex:page standardController="product_Development__c" extensions="HistoryPageController">
    <apex:form >
        <apex:pageblock title="VF Page Tabs" >
            <apex:tabPanel id="theTabPanel" value="{!tabOpt}" selectedTab="{!selectedTab}" >
                <apex:tab label="Basic Info" id="tab1" disabled="{!istab1disabled}">
                    <b>Name:</b><br/>
                    <b>closed Date:</b>
                    
                    <br/>
                    <b>Education Requirement:</b><br/>
                    <apex:commandButton value="Next" action="{!Next}" rerender="theTabPanel"/>
                </apex:tab>
                
                <apex:tab label="DetailPage" id="tab2" disabled="{!istab2disabled}">
                    <b>Apex:</b><br/>
                    <b>Max_Pay:</b>
                    
                    <br/>
                    <b>Min_Payt:</b><br/>
                    <apex:commandButton value="Previous" action="{!Previous}" rerender="theTabPanel" />
                </apex:tab>
            </apex:tabPanel>
        </apex:pageblock>    
    </apex:form>

</apex:page>

Hope this will help you.

Please let me know if it helped or you need any more assistance.

Please mark this is as the solution if it solved your purpose.

Thanks,
Sohan Raj Gupta

All Answers

Sohan Raj GuptaSohan Raj Gupta
Hi Naveen,

You can use below code:
 
public class HistoryPageController
{
    public String tabOpt {get;set;}
    private ApexPages.StandardController controller;

    public HistoryPageController(ApexPages.StandardController controller)
    {
    this.controller = controller;
     selectedTab = 'tab1';
    }
      
   
    
    private string selectedtab;

  public boolean getistab1disabled() {
    return selectedTab <> 'tab1';
  }

  public boolean getistab2disabled() {
    return selectedTab <> 'tab2';
  }

  public void Previous() {
    selectedtab = 'tab1';
  }

  public void Next() {
    selectedtab = 'tab2';
  }

  public string getselectedtab() {
     return selectedtab;
  }
}
 
<apex:page standardController="product_Development__c" extensions="HistoryPageController">
    <apex:form >
        <apex:pageblock title="VF Page Tabs" >
            <apex:tabPanel id="theTabPanel" value="{!tabOpt}" selectedTab="{!selectedTab}" >
                <apex:tab label="Basic Info" id="tab1" disabled="{!istab1disabled}">
                    <b>Name:</b><br/>
                    <b>closed Date:</b>
                    
                    <br/>
                    <b>Education Requirement:</b><br/>
                    <apex:commandButton value="Next" action="{!Next}" rerender="theTabPanel"/>
                </apex:tab>
                
                <apex:tab label="DetailPage" id="tab2" disabled="{!istab2disabled}">
                    <b>Apex:</b><br/>
                    <b>Max_Pay:</b>
                    
                    <br/>
                    <b>Min_Payt:</b><br/>
                    <apex:commandButton value="Previous" action="{!Previous}" rerender="theTabPanel" />
                </apex:tab>
            </apex:tabPanel>
        </apex:pageblock>    
    </apex:form>

</apex:page>

Hope this will help you.

Please let me know if it helped or you need any more assistance.

Please mark this is as the solution if it solved your purpose.

Thanks,
Sohan Raj Gupta
This was selected as the best answer
naveen reddy 68naveen reddy 68
Hi,
Sohan Raj Gupta, thanks for you help.