Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7436153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:11:37+00:00 2026-05-29T10:11:37+00:00

I have a VF page which has 2 date fields and search button. On

  • 0

I have a VF page which has 2 date fields and search button.

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.

I want to pass this date values into the printVF page. i also want to have this page come up as popup.

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.

Anybody has ideas on how to accomplish this?

Thanks

Prady

EDIT :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.

      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)+'&Penddate='+string.valueof(enddate1);
    return url;
}

public string geturlRec()
{
    urlRec='apex/VF2?Pstartdate='+string.valueof(startdate1)+'&Penddate='+string.valueof(enddate1);
    return urlRec;
}    

VF Page

   <script  language="javascript" type="text/javascript">
  function printOut()
  {

  window.open("{!url}");

      }
  function printIn()
  {
  window.showModalDialog("{!urlRec}","dialogWidth:800px; dialogHeight:200px; center:yes");

   }
   </script>


    <div style="width:900px;margin:0 auto;" id="pagediv">
     <span style="padding-left:30px;padding-right:10px">From </span><apex:inputfield value="{!fieldContainer.Start_Date__c}" id="startdt" style="padding-left:5px;padding-right:20px;"/>
   <span style="padding-left:30px;padding-right:10px">To </span><apex:inputfield value="{!fieldContainer.End_Date__c}" id="enddt" style="padding-left:5px;padding-right:20px;"/>

     <span style="padding-left:30px;padding-right:10px"><apex:commandButton action="{!search}" value="Search" ReRender="dtshipdep,dtshiprec,shippageblock">       </apex:commandButton></span>

     <apex:commandButton action="{!saveDeparted}" value="Update " ReRender="dtshipdep"></apex:commandButton>
    <apex:commandButton value="Print "  onclick="printOut();"></apex:commandButton>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:11:38+00:00Added an answer on May 29, 2026 at 10:11 am

    The salesforce recommended way to generate URLs is through URLFOR() function. Or, alternatively, you can create a PageReference in the extension/controller code.

    Though, keep in mind, before any form data can become part of the URL it has to be posted to the server and come back in newly generated pageReference, for that reason you cannot jut click on it in the first run.

    One way I used to solve this server side is using this code on VF

    <apex:outputBlock rendered="{!openPopup}">
       <script>
          window.open('{!myTargetUrl}');
       <script>
    </apex:outputBlock>
    

    openPopup is a bool that control whether this segment gets rendered (transient, you set it to true when you click on open button). myTarget is a PageReference based URL (alternatively you can use URLFOR here to generate URL in VF). If you have any more questions, ask.

    Another option is to have your javascript code in VF which will pickup button click event and build the URL client side and open it up. You can use $Component to locate form fields.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have small page which has label, DropDownList and a submit button. <div> <asp:label
I have an iFrame which has it's source set to another aspx page. The
Hi have a page which has List data. When I click on an element
I have a page which has a rectangular area with text and icons in
I have a page which has an Html.DropDownList which takes in a viewdata parameter.
I have a page which has an Iframe. In that Iframe, there are six
I have a page which has several <canvas> elements. I am passing the canvas
I basically have a page which shows a processing screen which has been flushed
I have a statistics page which has a meta refresh tag on it. <meta
I have an html page which has a link called open. Once the link

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.