You need to sign in to do that
Don't have an account?
Newbie VF question.
I am trying out some of the discussions in the SFDC cookbook and just not making any headway. Page 54 talks about overriding the Account Tab with a VF page based on the user's profile id. This seems easy enough however I would like to do this with a custom object, Contracts__c , that we in place. The steps outlined are;
1. Create standard account page page
2. Create the custom account page
3. create the controller extension in a APEX class.
4. Add the profiles via the Security settings for the new pages/
4. Override the Account tab with the page created in step 1.
For Step 1, I substituted our custom object instead of 'account':
<apex:page standardController="Contracts__c" extensions="overrideCon"
action="{!redirect}">
<apex:detail />
</apex:page>
However, when I go to the Contracts__c object to over ride the Contract tab the VF page that I created is not listed. I'm
{
String recordId;
public overrideCon(ApexPages.StandardController controller){
recordId = controller.getId();
}
public PageReference redirect(){
Profile p = [select name from Profile where Id = :UserInfo.getProfileId()]; if('Symyx Support - Tools'.equals(p.name)){
PageReference customPage = Page.customContractPage;
customPage.setRedirect(true);customPage.getParameters().put('Id',recordId);
return customPage;}
else
{
return null; }
}
Pages that use the standard controller for an object cannot be used as an override for the Tab view of that object. Using the standard controller implies that you are only dealing with one record (such as in your constructor, where you're pulling the id off of your controller). Therefore it only makes sense to use this page as an override for a New, Edit, Detail, etc. view -- basically any views that are specific to manipulating or viewing one record.
To override the Tab view you will either need a page that uses a Standard List Controller, or no controller, or a custom controller. I believe all of this is documented in the Visualforce Developer Guide.
All Answers
Pages that use the standard controller for an object cannot be used as an override for the Tab view of that object. Using the standard controller implies that you are only dealing with one record (such as in your constructor, where you're pulling the id off of your controller). Therefore it only makes sense to use this page as an override for a New, Edit, Detail, etc. view -- basically any views that are specific to manipulating or viewing one record.
To override the Tab view you will either need a page that uses a Standard List Controller, or no controller, or a custom controller. I believe all of this is documented in the Visualforce Developer Guide.
Hi Jill.... Thank you for your response. What I find confusing is that the example I was using is pretty much the same as given in the SFDC Cookbook, page 54, in overriding a tab. Is it safe to say that the example in the Cookbook is incorrect?
Regards......
Hi Jill... Thanks for getting back to me. The example I'm using is shown under the 'Discussion' section where it states:
"To override the Account tab with a custom VF page only for users with ...... ( certain profiles ). "
This VF page is supposed to be saved as 'standardAcctPage' and then used in the tab override section of the object.
extensions="overrideCon"
action="{!redirect}"><apex:detail />
</apex:page>
Except I used 'Contracts__c' for account: I do see in the first example where it is using a Standard List Controller, but the example here seems to show just the standard Controller??
If I add the the recordSetvar="accounts" to the example I recieve a error on the extenstion line as invalid.
Okay I see. The first example shows a standard list controller. The second should probably specify overriding a detail page rather than a tab view. I will log a bug to our doc writers for this, thanks!
Once you add the recordSetVar attribute yes, you will need to change or add a constructor that takes in a StandardSetController instead of a StandardController.
I am not able to create a custom controller for a page, everytime I create the controller attribute and save it to the page I get this error:
Error: Apex class 'CountiesByState' does not exist