title: How to open a VF page as popup and pass parameters to that VF page?
body: <p>I have a VF page which has 2 date fields and search button.</p>
  
  <p>On click of search i get some results. i also have another button to print those results which is nothing but a new VF page rendered as pdf.</p>
  
  <p>I want to pass this date values into the printVF page. i also want to have this page come up as popup.</p>
  
  <p>I have the pageref with parameters set. Since i need to open this page as popup i need to find a way to use the pageref in the window.open.</p>
  
  <p>Anybody has ideas on how to accomplish this?</p>
  
  <p>Thanks</p>
  
  <p>Prady</p>
  
  <p><strong>EDIT</strong> :What i did was build the url in the controller and use the controller variable in window.open. Something very strange is happening... The first time search results are displayed and i click the print button, the dates dont get populated in the string, they default to todays date.. if i again click the print button the dates are populated correctly on the url from the dateinput.</p>
  
  <pre><code>      public Class1(){
        System.debug('inside constructor');
         fieldContainer=new DummyTable__c(); // it contains date fields for date inputs
        date todays=date.today();
  
       If (fieldContainer.Start_Date__c== null)
       {
          startdate1=todays;
       }else
       {
       startdate1=fieldContainer.Start_Date__c;
       }
  
       If (fieldContainer.End_Date__c== null)
       {
          enddate1=todays;
       }
       else
       {
       enddate1=fieldContainer.End_Date__c;
       }
       }
  
       public void search()
  {
  
      startdate1=fieldContainer.Start_Date__c;
      system.debug('startdate1'+startdate1);
  
  
      enddate1=fieldContainer.End_Date__c;
      system.debug('enddate1'+enddate1);
      system.debug('inside search()....after clicking search button');
      system.debug('startdate1'+startdate1);
      system.debug('url'+url);
      LoadData();
  }
  
      public string geturl()
  {
      url='apex/VF1?Pstartdate='+string.valueof(startdate1)+'&amp;Penddate='+string.valueof(enddate1);
      return url;
  }
  
  public string geturlRec()
  {
      urlRec='apex/VF2?Pstartdate='+string.valueof(startdate1)+'&amp;Penddate='+string.valueof(enddate1);
      return urlRec;
  }    
  </code></pre>
  
  <p>VF Page</p>
  
  <pre><code>   &lt;script  language="javascript" type="text/javascript"&gt;
    function printOut()
    {
  
    window.open("{!url}");
  
        }
    function printIn()
    {
    window.showModalDialog("{!urlRec}","dialogWidth:800px; dialogHeight:200px; center:yes");
  
     }
     &lt;/script&gt;
  
  
      &lt;div style="width:900px;margin:0 auto;" id="pagediv"&gt;
       &lt;span style="padding-left:30px;padding-right:10px"&gt;From &lt;/span&gt;&lt;apex:inputfield value="{!fieldContainer.Start_Date__c}" id="startdt" style="padding-left:5px;padding-right:20px;"/&gt;
     &lt;span style="padding-left:30px;padding-right:10px"&gt;To &lt;/span&gt;&lt;apex:inputfield value="{!fieldContainer.End_Date__c}" id="enddt" style="padding-left:5px;padding-right:20px;"/&gt;
  
       &lt;span style="padding-left:30px;padding-right:10px"&gt;&lt;apex:commandButton action="{!search}" value="Search" ReRender="dtshipdep,dtshiprec,shippageblock"&gt;       &lt;/apex:commandButton&gt;&lt;/span&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>     &lt;apex:commandButton action="{!saveDeparted}" value="Update " ReRender="dtshipdep"&gt;&lt;/apex:commandButton&gt;
      &lt;apex:commandButton value="Print "  onclick="printOut();"&gt;&lt;/apex:commandButton&gt;
  </code></pre>