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
adsfasdfasdfasdadsfasdfasdfasd 

I need to know the ENTIRE url of the calling page ...

I need to find out what the ENTIRE url of the calling page is in VF, so that I can return to that URL.

 

I can't append the retUrl to the querystring on the button because &retUrl=%2F{object__c.Id} doesn't include the base url. 

 

I can't derive the retUrl from the object's record ID because I don't know the base URL and the base URL will change depending on circumstances.

 

I can't use ApexPages.currentPage().getHeaders().get('Referer') because that just returns "/". I thought maybe I was spelling "referer" wrong -- because it is actually spelled "referrer" in the HTML spec so I tried that, too, and it returned an empty string.

 

I can't use ApexPages.currentPage().getHeaders().getUrl() because that returns the CURRENT url.

I can't use ApexPages.currentPage().getHeaders().get('Host') because that returns the CURRENT host, and the current host is some weird VF thing instead of https://na*.salesforce.com.

 

And I can't use javascript (document.referrer) because that just returns an empty string, too.

 

I need a result that looks something like this: https://na6.salesforce.com/a0580000005XeTg

 

How can I do this?

 

TIA,

 

John

 

 

prageethprageeth

I don't know whether you are looking for something like this.

 

String s1 = 'https://';

String s2 = ApexPages.currentPage().getHeaders().get('Host');

String s3 = Apexpages.currentPage().getUrl();

return s1 + s2 + s3;

adsfasdfasdfasdadsfasdfasdfasd
Sorry, no, that gives me information about the CURRENT page. I need the know the URL of the PREVIOUS (calling) page ...
CaptainObviousCaptainObvious

I havent tried it myself, but how about something like this:

 

Create your button with OnClick JavaScript...

var callingPage=document.location; top.location("/apex/vfpage?refURL="+callingPage);

where vfpage is your custom Visualforce page. You can then access the refURL parameter in your controller.

If you're passing other parameters to the vf page, append the refURL parameter at the end.

prageethprageeth

If you like JavaScripts;

 

<apex:commandButton value="Cancel" onclick="history.go(-1);return false;"/> 

cmerrillcmerrill

You can determine HTTP or HTTPS by using the following:

 

ApexPages.currentPage().getHeaders().keySet().contains('CipherSuite');

 

https returns true, http returns false