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
Naresh Krishna.ax1176Naresh Krishna.ax1176 

How to open the window in new tab for each onclick ?

Hi All,


I am using below piece of code to open the window in new tab:


<apex:dataList  value="{!displayWindows}" var="window">

    <apex:commandLink style="text-decoration:none" action="{!openwindow}" target="__blank{!window.windowId}" >



</apex:dataList >

Its not working completly.

When i click on commandLink first time,  it opens in new tab.

But i click on again, it refreshes the previously opened tab but not opened in new tab.


Can anyone please help me with this.




can u plz share u r apex code 2 so i can understand about this {!window} paramter

it may be a case the the new page that is open the code of command link mit get chage u can look into it's sorce code to find out the difference b/w link in main window & the newly open window

Naresh Krishna.ax1176Naresh Krishna.ax1176


On brief, code is as follows:-


List<WindowVO> windows = new List<WindowVO>();

WindowVO vo1 = new WindowV();




WindowVO vo2 = new WindowV();









In Place of using  <apex:commandLink> you can use <a her></a> 


for look into the ref code to replicate u r case i create a wrapper class with name as WindowVO


Apex Class


public class commhelp1
public PageReference p1{get;set;}
public list<WindowVO> displayWindows{get;set;}
public commhelp1()
    p1 = null;
    displayWindows = new list<WindowVO>();
    WindowVO vo1 = new WindowVO();
    vo1.WindowId = '1';
    vo1.WindowName = 'window1';
    WindowVO vo2 = new WindowVO();
    vo2.WindowId = '2';
    vo2.WindowName = 'window2';
public class WindowVO
   public String WindowId{get;set;}
   public String  WindowName{get;set;}

public PageReference openwindow()
    p1=new PageReference('/apex/commhelpPage1');
    return p1;






<apex:page controller = "commhelp1" cache="false">
  <apex:dataList  value="{!displayWindows}" var="window">

         <a href="{!p1}" target="_blank"> {!window.windowName} </A>

</apex:dataList >


If u havw any query u can replay me back

Thanks & Regards