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

Default Tab Rendering based on Profile

We are using the tabbed layout and want to be able to have the default tab change based on the profile of the user.


Theoretically it would look something like this

<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" 
selectedTab="IF($Profile.Name=='Inside Sales',salesinfo,(IF($Profile.Name=='Accounting',Financials,dealinfo)))">

 Thinking I should do this in apex.  Anyone have any experience with this?



Shashikant SharmaShashikant Sharma

Use controller getter method


Controller :


public class TabPanel 

    public String getSelectedTab()
      String ProfileName = [Select Name from Profile where id =: UserInfo.getProfileId()].Name;
      if(ProfileName == 'System Administrator')
          return 'name2';
          return 'name1';    


<apex:page id="thePage" controller="TabPanel">
<apex:tabPanel switchType="client" id="theTabPanel" value="{!SelectedTab}">
    <apex:tab label="One" name="name1" id="tabOne">content for tab one</apex:tab>
    <apex:tab label="Two" name="name2" id="tabTwo">content for tab two</apex:tab>

 In this example I have used value attribute of tabPanel component.


I hope it solve your problem, please let me know in case any issue in it.