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
jhartjhart 

bug: Overriding a custom object tab with a Visualforce page does not work.

I've got a custom object that I want to have rooted on a tab that uses one of my Visualforce pages.

On Setup > Build > Tabs, if I built a "Visualforce Tab", the tab shows up and works but is never highlighted, so it looks like it's not selected even when it is.  Maybe there's some magic "tabStyle" value that I can use to force my visualforce tab to highlight, but I have no idea what it is.

Alternately, in Setup > Build > Tabs I can create a "Custom Object Tab", which highlights perfectly.  However, by default it shows the standard list view rather than my desired Visualforce page.

This seems to be exactly what the "Standard buttons and links" "override" function is for.

So I go to Setup > Build > Objects, select my custom object, and "override" the standard "Tab". I point that override at my desired Visualforce page (using the "page" radio button and then choosing via the drop-down).

Now when I click on my custom object tab, I get an error message ("URL No Longer Exists").

So, basically, if you have a custom object tab & then override the tab location using a Visualforce page, it doesn't work.  I think this is one of two use cases of the "override" function for tabs (the other being an s-control), so this seems to be a bug.
aballardaballard

Hm, I just tried both of these and they seemed to work ok for me...

.. if I define a VF page tab, when I select that tab it displays the page and highlights the tab.   The tab would not be highlighted if you go to the page in any other way, however.

.. I defined a custom object, created a custom object tab for it, defined override for tab to go to a VF page and it worked ok.  Perhaps there is something your page is trying to do that is the problem? 

jhartjhart
aballard,

Thanks for checking it out.  The page itself works fine - I've been using it under the non-highlighted tab for months now - but your success inspires me to try again using completely stripped-down tests cases.  I'll post what I find.

-john
jhartjhart
OK, some results.

(1) If you want a page to be the root of a VForce tab, do not declare a "tabStyle" for the page.  Doing so will cause the tab to not highlight.

My vforce page was declaring its tab style.  When I got rid of that declaration, the VForce tab did correctly highlight.

However, I have four pages that I need to live beneath that VForce tab, and I have no way of making the other 3 pages keep the tab highlighted.  (I suspect there is a magic "tabStyle" that I can declare to make a certain vforce tab remain highlighted, but I don't know what it might be).

(2) Conversely, if you want a page to be the root of a "Custom Object" tab (by overriding the Tab view definition for that Custom Object), you must declare the page's tabStyle to be that custom object.  Any other pages declaring the same tabStyle  will keep the "Custom Object" tab highlighted too.


It seems that (2) is the right way for me to go, because that way all of my pages can declare the custom object type as their tabStyle and the tab will remain highlighted.


Now my challenge is to figure out why the custom object tab override works fine for a test page but gives a "page not found" error when pointed at my desired page (which I've been using for months and which works fine when navigated to in any other way).


aballard, thanks again for your reply. I would have sat resignedly for some time if you hadn't posted.
jhartjhart
OK, I've isolated the bug that leads to "page not found" errors.

Visualforce pages that are used to override an objects' Tab cannot contain an <apex:inputField> that is used to set a lookup relationship.

For example, if you have this test page:

Code:
<apex:page controller="CtlTest">
<apex:form>
Account: <apex:inputField value="{!contact.AccountId}"/>
</apex:form>
</apex:page>

With this simple controller:


Code:
public class CtlTest {
 Contact c = new Contact();
 public Contact getContact() {
  return c;
  }
 }


The page will work fine, for example as the root of a Visualforce tab:




However, use that exact same page to override an object's tab, and you get an error:





My only guess would be that the code generator for the <apex:inputField> element is using a relative path to get to its source, and this relative path is broken by the overriden tab URL (https://na5.salesforce.com/a0A/o) whereas it works in a standard apex URL (https://na5.salesforce.com/apex/testObjTab).





 

mtbclimbermtbclimber
I just tried your last sample on the new release and it seems to be working. Looks like you are on NA5 which was updated last night/this morning.

Can you try it one more time and let us know what you find?

Thanks
jhartjhart
Andrew,

The new release does fix it!

That's great, b/c otherwise my only recourse was to override the tab with a page that used client-side javascript to redirect to my vforce page.  Glad that this layer of indirection is no longer need.

One note: when accessed via the tab, the path to the page is different (it's no longer /apex/mypage but instead /a04/o).  So relative paths between sibling apex don't work if one of them is accessed via the tab.  Not a major issue, but an interesting side-effect of the way custom tab overrides were implemented (changing the given page for the same URL, rather than changing the tab's URL itself).

thanks,
john

vivekanandanvivekanandan

Hi,

 

Even I am having the same problem, I have createdA VF page. When i try to override with a custom object tab,

 

When I select vf page in the radio button and opened the list of vf pages, i am not able to see the vf page which i have created. I was surprised .

 

I have removed the tab style also from the vf page.

 

Please suggest.