+ Start a Discussion
KeithlarsKeithlars 

Navigation problem in Tabbed Accounts in 30 seconds

I created tabs following the Tabbed Accounts in 30 seconds post and my problem is that whenever I perform an action on any tab other than the detail tab I'm returned to the detail tab after the action is completed instead of returning to the tab I was on.  

 

I tried to find code samples that my lead me to an answer and I thought maybe I had to create an standard controller extension which I attached below.  However, I'm very green at this so I don't really know how to continue so any direction and sample code would be greatly appreciated.  I'm sure I'm not the only one who has implemented this cool technique and has run into this problem.

 

Keith

 

VS Page:

 

<apex:page standardController="Account" extensions="accountExt" id="p"
showHeader="true" tabStyle="account" >
<apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel">
<apex:tab label="Details" name="AccDetails" id="tabdetails">
<apex:detail relatedList="false" title="true"/>
</apex:tab>
<apex:tab label="Contacts" name="Contacts__r" id="tabContact">
<apex:relatedList subject="{!account}" list="contacts__r" />
</apex:tab>
<apex:tab label="Invoices" name="Invoices" id="tabInvoice">
<apex:relatedList subject="{!account}" list="invoices__r" />
</apex:tab>
<apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct">
<apex:relatedList subject="{!account}" list="OpenActivities" />
</apex:tab>
<apex:tab label="Products Offered" name="ProductsOffered" id="tabProdOffer">
<apex:relatedList subject="{!account}" list="Products_Offered__r" />
</apex:tab>
<apex:tab label="Products Sold" name="ProductsSold" id="tabProdSold">
<apex:relatedList subject="{!account}" list="Product_Releases__r" />
</apex:tab>
</apex:tabPanel>
</apex:page>

 Controller:

 

public class accountExt {

String aId;
String pId;

public accountExt(ApexPages.StandardController controller) {
aId = ApexPages.currentPage().getParameters().get('aId');
pId = ApexPages.currentPage().getParameters().get('pId');
}

public PageReference redirect(){
PageReference pageRef = new PageReference('/'+pId);
pageRef.setRedirect(true);
return pageRef;
}

public void setState(String n) {
state = n;
}

public String getState() {
return state;
}

public PageReference methodOne() {
return null;
}

private String state = 'no';
}

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
JpaqJpaq

I'm having a different navigation issue...  In the tutorial, the final screen shot ("Your page should now look like this: ") shows, between the header and tabs, a critical link: 

 

 Back to List

 

I've customized the sample to a good extent, but even copying the code right out of the tutorial does not give me that link. 

 

For clarity, I'm looking for the ability to return to the Account list view from the tabbed page.  My users utilize List views extensively, and need the ability to choose an Account in the list and navigate directly back to that list.  I've tried custom controllers with no luck (addressed in a similar thread;  for some reason the retURL isn't being passed to the custom VF page?).   Since "Back to List" is all over the standard pages, it seems I'm missing something simple. 

All Answers

parkerAPTparkerAPT

I do not think that SF allows you to automatically cache the selected tab.

 

You may want to type two things, I don't know if they will work:

 

  1. Set the switch Type from "client" to "ajax" or "server" ( This may force SF to save the state of the selected tab)
  2. Another alternative may be to store the selected Tab Name in your custom controller and control which tab is displayed using something like: selectedTab="{!selectedTabName}".  You'd have to keep track of this in the controller when various actions were performed. 
KeithlarsKeithlars

Changing the switchType to ajax or server didn't work. 

 

I don't see how I could keep track of all the actions that can be performed on related lists so I need to find another solution.

ShikibuShikibu

The link to the tutorial is http://wiki.developerforce.com/index.php/Tabbed_Accounts_in_30_seconds

Message Edited by Shikibu on 03-23-2009 11:39 AM
acunycacunyc

The tutorial clearly does not address this issue.

 

I, and others I have seen post in other places, continue to have an issue with this.

 

Any help would be appreciated.

ShikibuShikibu

Whoops -- I didn't mean to imply that the answer was in the tutorial. Rather, I'm new to VF, and when I ready your post I wanted to view the tutorial. It wasn't simple to hunt down, so I thought I would post the link to save other (and myself, at a later date) the trouble of hunting for it.

 

Sadly, I don't know how to solve your problem.

Frenchy52Frenchy52

I am trying to do the same thing with my account layout and it always tells me that this related list is not  a child of the account object. Do all the related list have to be children of the account so that can work?

thanks.

acunycacunyc

yes, they do have to all be children of the object that your controller is related to.  Think of this internal tab as just a way of reorganizing the detail page.  Instead of having the related lists at the bottom, they are now spread across tabs.

 

You can however put anything you want to inside one of the tabs.  Instead of putting in the associated related list, you can use a custom controller to get any information you wish and then put that in the tab.

 

That is what I am doing on one of my pages.  I'm creating my own custom lists under the tabs.  If you are not familliar with controller extensions or custom controllers you will need to become familliar with them.  Also, you will have to be able to write the apex methods necessary (SOQL statements in this case) to pull in the info you need...

 

I hope this helps.

 

Drew

Frenchy52Frenchy52

Drew,

Thanks for the reply, however you can have 2 types of related lists at the account level; a related list that comes from a lookup and arelated list that come from a master detail relationship. Most of my related lists come from lookkups to accounts in other objects. That's where the limitation seems to be.

Tom

JpaqJpaq

I'm having a different navigation issue...  In the tutorial, the final screen shot ("Your page should now look like this: ") shows, between the header and tabs, a critical link: 

 

 Back to List

 

I've customized the sample to a good extent, but even copying the code right out of the tutorial does not give me that link. 

 

For clarity, I'm looking for the ability to return to the Account list view from the tabbed page.  My users utilize List views extensively, and need the ability to choose an Account in the list and navigate directly back to that list.  I've tried custom controllers with no luck (addressed in a similar thread;  for some reason the retURL isn't being passed to the custom VF page?).   Since "Back to List" is all over the standard pages, it seems I'm missing something simple. 

This was selected as the best answer