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
sbrmathsbrmath 

CommandLink and spawning a new window

target="_blank" is not working with rerendered attribute for CommandLink.

It is not spawning a new window as expected, the results are displayed in the current browser window.

If i remove rerendered, clicking on the link spawns the new window.

 

Is this a known issue? is there a workaround for this?

 

<apex:commandLink rendered="{!result.isXYZAccount == 'NO-ADD'}" value="{!result.isXYZAccount}" action="{!loadGuest}" target="_blank" rerender="abc,xyz"/>

 

Best Answer chosen by Admin (Salesforce Developers) 
WesNolte__cWesNolte__c

Hey

 

It's meant to work this way i.e. the rerender attribute stops navigation to a new page, and says, "Visualforce page ol' chap, why not partial page refresh that bit over there for me.". 

 

This being the case I'd say prageeth's options is a good one, although I'd move it to the oncomplete event handler:

 

oncomplete="window.open('/apex/myPopupPage');" 

 

This way you'd know that your apex code had run before you open the new page. 

 

Wes 

All Answers

prageethprageeth

Hello sqrt.math

Hello sbrmath;

Why don't you try "window.open" method? you can popup the second page as below.

 

If the name of your popup page(Second page) is 'myPopupPage' you can popup the second page as below.

 

<apex:commandLink rendered="{!result.isXYZAccount == 'NO-ADD'}"

value="{!result.isXYZAccount}"

action="{!loadGuest}"

rerender="abc,xyz"

 onclick="window.open('/apex/myPopupPage');"/> 

 

WesNolte__cWesNolte__c

Hey

 

It's meant to work this way i.e. the rerender attribute stops navigation to a new page, and says, "Visualforce page ol' chap, why not partial page refresh that bit over there for me.". 

 

This being the case I'd say prageeth's options is a good one, although I'd move it to the oncomplete event handler:

 

oncomplete="window.open('/apex/myPopupPage');" 

 

This way you'd know that your apex code had run before you open the new page. 

 

Wes 

This was selected as the best answer
sbrmathsbrmath

the loadGuest call returns a pagereference and i am trying to open this in the new window and at the same time refresh the parent window.

 

WesNolte__cWesNolte__c

In that case I would recommend using an action function e.g.

 

 

<apex:actionfunction name="myFunction" rerender="abc,xyz" /> 

<apex:commandLink rendered="{!result.isXYZAccount == 'NO-ADD'}" value="{!result.isXYZAccount}" action="{!loadGuest}" target="_blank" oncomplete="myFunction();"/>

 

Wes