You need to sign in to do that
Don't have an account?

Tab, How do pass back to your controller
Hello,
I am working on developing a tabbed page in Visualforce but would like to know which tab the user is viewing. If there is a way to determine this, I can cut a lot of code and buttons from the page view.
Anyone have a suggestion or a fast code example?
Thanks
Try modifying your <apex:tabPanel> tag as shown below :-
<apex:tabPanel switchType="Ajax" value="{!selectedTab}" id="theTabPanel" activeTabClass="activeTab" inactiveTabClass="inactiveTab"
height="300%" headerSpacing="5">
All Answers
Try this out -)
Controller:
public class Tabs {
public String SelectedTab { get; set; }
}
VF:
<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>
Thanks for the response. How does it push back the tab name that it's currently on? My system.debug('>>>>>>>>> Tab is ' + selectedTab); keeps telling me the value is null no matter if its on load or when clicking a tab.
Did you specify the name attribut on <apex:tab> tag?? If not include the name attribute values in each <apex:tab> tag and the selectedTab will return the name value, thereby identifying the selected tab.
Yes, I believe so, here is the code.
Controller has this embeded at the beginning.
What am I doing wrong?
Try modifying your <apex:tabPanel> tag as shown below :-
<apex:tabPanel switchType="Ajax" value="{!selectedTab}" id="theTabPanel" activeTabClass="activeTab" inactiveTabClass="inactiveTab"
height="300%" headerSpacing="5">
This worked, the only issue is for anyone reviewing is that you need to set the value initially as it will be null the first time the page opens. I set it to a default only if null will fix it.
thanks again.