You need to sign in to do that
Don't have an account?
Ben Merton 15
Calling a controller into a VisualForce page URL
I am using this code to return the first three letters of a Custom Object's id, so that I can then bypass the standard object landing page and go straight to a list view of that Custom Object:
I am not clear exactly how I am meant to now call this into a VisualForce page:
//This class is used as a controller for allowing the Corporate Statements tab to land directly on the List View public class PageRef{ public PageReference exit(){ //change the Any_ObjectName__c with your Custom or Standard Object name. Schema.DescribeSObjectResult anySObjectSchema = Corporate_Statements__c.SObjectType.getDescribe(); String objectIdPrefix = anySObjectSchema.getKeyPrefix(); PageReference pageReference = new PageReference('/'+objectIdPrefix+'/o'); pageReference.setRedirect(true); return pageReference; } }
I am not clear exactly how I am meant to now call this into a VisualForce page:
<apex:page controller="PageRef"> action = "{!URLFOR(pageReference)}; </apex:page>Any help?
Your controller code is fine.
On the visualforce page add the "action" property in "apex:page tag" like,
<apex:page controller="PageRef" action = "{!exit}">
</apex:page>
This should solve your issue.
Thanks
Nitin
All Answers
Change your method name as getExit as below and use the below page as reference: Page:
Your controller code is fine.
On the visualforce page add the "action" property in "apex:page tag" like,
<apex:page controller="PageRef" action = "{!exit}">
</apex:page>
This should solve your issue.
Thanks
Nitin
Thanks, but now the page isn't loading at all. It seems to be looping on this URLhttps://c.na22.visual.force.com/apex/CorporateStatementsListView?save_new=1&sfdc.override=1
And switching between 'waiting for c.na22.visual.force.com and na22.visual.force.com??
Ben
Have you overriden the view page or something, could you tell me what exactly do you want to do?
Thanks
Nitin
I am trying to override the standard landing page of a custom tab. ie, I want to be able to click on a tab and have it point directly to the List View for that tab without having to go to the 'Recent Items' page. I have updated the Custom Tabs Button to redirect to the VisualForce page, but it isn't open (ie yes the Custom Tab functionality is overridden - it is now pointing to the VF page that you have referenced above, but it isn't loading)
Ben
The profile with which you are checking has access to that page right?
Just to confirm the code is correct:
VF:
Controller: