Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Visualforce Development
- :
- Redirecting to a specific tab in a tabpanel
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Redirectin g to a specific tab in a tabpanel
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-14-2012 08:57 PM
Hi,
I am at present working on a visualforce interface similar to the one shown at:
http://www.salesforce.com/us/developer/docs/pages/
I would like to redirect to a specific tab under the Accounts tab. For example the opportunities tab under the Account tab using the URLFOR function.
I could not find any examples that did this which is why I am little puzzled about how to go about this.
Thanks in advance.
nav
Re: Redirectin g to a specific tab in a tabpanel
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-16-2012 12:38 AM
You can use the selectedTab attribute in <apex:tabPanel>, it determines the tab that is selected. So when you want to redirect to Opportunity Tab, you can simply have the selectedTab set dynamically and assign it the Opportunity Tab Name.
See example:
<apex:tabPanel switchType="client" selectedTab="{!selectedTab}" id="AccountTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab">
<apex:tab label="Details" name="AccDetails" id="tabdetails">
<apex:detail relatedList="false" title="true"/>
</apex:tab>
<apex:tab label="Contacts" name="Contacts" id="tabContact">
<apex:relatedList subject="{!account}" list="contacts" />
</apex:tab>
</apex:tabPanel>
If you want to launch this from some other link/page, add this parameter - /apex/yourpagename?tab=Opportunities
and then in your controller, your constructor should assign the parameter value to 'selectedTab' variable.
selectedTab = ApexPages.currentPage().getParameters().get('tab')
I hope this clears your doubt!
Kudos a post if it helps, mark it as solution if it solves.
http://exploretheforce.blogspot.in
Re: Redirectin g to a specific tab in a tabpanel
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-16-2012 02:25 AM
Thanks Vishal,
But I am afraid I am still having problems. My code for the controller is below:
public with sharing class Administration {
public String selectedTab { get; set; }
public Administration() {
// selectedTab = 'accounts';
}
public String getSelectedTab() {
ApexPages.currentPage().getParameters().get('tab') ;
if (selectedTab == null) {
System.debug('inside if');
selectedTab = 'accounts';
}
else {
System.debug('inside else');
}
System.debug('=================' + selectedTab + '================');
return selectedTab;
}
}and my visualforce pages looks like this:
<apex:page controller="Administration" showHeader="true" sidebar="false" tabStyle="Administration__tab">
<apex:tabPanel switchType="server" id="theTabPanel" selectedTab="{!selectedTab}">
<apex:tab label="Accounts" id="accounts">
<h2 style="font-size: 150%; margin-left: 5px; margin-top:5px; display: block;">Accounts</h2>
<apex:enhancedList type="Account" height="600" rowsPerPage="25" id="AccountList" />
</apex:tab>
<apex:tab label="Projects" id="projects">
<h2 style="font-size: 150%; margin-left: 5px; margin-top:5px; display: block;">Projects</h2>
<apex:enhancedList type="Project__c" height="600" rowsPerPage="25" id="ProjectList" />
</apex:tab>
<apex:tab label="Milestones" id="milestones">
<h2 style="font-size: 150%; margin-left: 5px; margin-top:5px; display: block;">Milestones</h2>
<apex:enhancedList type="Milestone__c" height="600" rowsPerPage="25" id="MilestoneList" />
</apex:tab>
<apex:tab label="Activities" id="actvities">
<h2 style="font-size: 150%; margin-left: 5px; margin-top:5px; display: block;">Activities</h2>
<apex:enhancedList type="Activity__c" height="600" rowsPerPage="25" id="ActivityList" />
</apex:tab>I cannot see any of the debug statements show up in my system log.
The edit and delete links in the enhanced list are overriden by a visualforce page that has a single script tag like so:
<script type="text/javascript">
window.top.location.replace("{!URLFOR($Action.Proj ect__c.Edit, Project__c.id, [saveURL='/apex/Administration?tab=projects', retURL='/apex/Administration?tab=projects', cancelURL='/apex/Administration?tab=projects'], true)}");
</script>which adds the appropriate tab name in my case my tabs are called accounts, projects, milestones and actvities. When I click the edit link for a particular project it goes to the standard edit page and then redirects back to the Administration tab this bit works. But I would also want it to select the project tab under the tab panel for where the edit link was clicked on.
The tab variable is assigned in the URL and I can see it but I think it is not assigned for some reason.
Would be most grateful for any pointer you could give me.
Thanks in advance.
nav
Re: Redirectin g to a specific tab in a tabpanel
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-16-2012 03:57 AM
Hey,
I went through your code. In the method getSelectedTab()
You are not assigning the usl parameter value to the variable 'selectedTab'. You are only checking if it is null, else you returning the default value (accounts).
public String getSelectedTab() {
selectedTab = ApexPages.currentPage().getParameters().get('tab')
if (selectedTab == null) {
System.debug('inside if');
selectedTab = 'accounts';
}
else {
System.debug('inside else');
}
System.debug('=================' + selectedTab + '================');
return selectedTab;
}
You need to assign the url parameter to the variable. Please try making the above change and let me know if that works correctly.
Kudos a post if it helps, mark it as solution if it solves.
http://exploretheforce.blogspot.in
Re: Redirectin g to a specific tab in a tabpanel
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-16-2012 04:58 AM
Sorry I had it right in my code just pasted it wrong. According to the logs my getSelectedTab method is not even being entered into.
So there is somethng I have done wrong here.
Should I put all the code into the constructor and see if that works.
Grateful for any pointers you maybe able to give me.
Thanks,
nav
Re: Redirectin g to a specific tab in a tabpanel
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-18-2012 05:35 AM
Solved the problem instead of setting selectedTab="{!selectedTab}" setting value="{!selectedTab}" works for me flawlessly. Found the solution at the followinh link:
Hope this helps someone. :-)
Cheers,
nav

