0

so I have a page reference implemented in my apex page

PageReference mypage=new PageReference('http://10:7:8...') 

which should ideally be opening in a new tab hitting the url mentioned on the click of a command button. However for the past couple of days the on clicking the button the following thing happnes

  1. the word webpage gets appended in the url along with the base url so it is like https://domainseal--navsbx.lightning.force.com/webpage/

  2. Along with this the page reference url gets appended in the encoded format so for example if the pagereference url is https://meyerweb.com/eric/tools/dencoder/ it is being displayed as https%3A%2F%2Fmeyerweb.com%2Feric%2Ftools%2Fdencoder%2F in the url

so in essence the final url which is showing up on clicking the command button is

The base url/webpage/encoded pagereference url 

and the page is showing with a message

"This page isn't available in Salesforce Lightning Experience or Salesforce1"

and also using command link and using target=_blank is not possible since there are validation checks involved which will not be visible since it will invariably open in the new tab

  • Need urgent help on the issue – Victor Mitra Jan 13 at 16:41
0

you can put your command button wrapped in command link like below.

<apex:page controller="testURLNavigationCtrl">
<apex:form>
    <apex:commandlink action="{!navigateTogoogle}" target="_blank">
        <apex:commandButton  value="redirect" />
    </apex:commandlink>
</apex:form>

That will open a new window.

and leave your Page reference method as it is.

   public PageReference navigateTogoogle(){
   PageReference pageRef = new PageReference('http://www.google.com');
    pageRef.setRedirect(true);
    return pageRef;
}

That should work.

  • No,since there are validation checks as i mentioned in the controller itself,it wont display those apex:page errors ,instead it will reirect to the url invariably – Victor Mitra Jan 14 at 17:28

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.