You need to sign in to do that
Don't have an account?
List Controller New Window PDF
Hi Guys,
I have the following visualforce page
<apex:page standardController="Production_Request__c" recordSetVar="requests" extensions="productionRequestPrinter" showHeader="false" id="prprinter"> <apex:form > <apex:pageBlock title="Selected Production Requests" id="muselectedlist"> <apex:pageBlockTable value="{!selected}" var="opp" id="mutab"> <apex:column value="{!opp.name}" id="oppname"/> </apex:pageBlockTable> <apex:pageBlockButtons location="top" id="mubut"> <apex:commandButton action="{!doPDF}" value="Print" id="butprint"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
And the following class extension at the moment
public with sharing class productionRequestPrinter { public ApexPages.StandardSetController setCon; public PageReference pageRef = ApexPages.currentPage(); public productionRequestPrinter(ApexPages.StandardSetController controller) { setCon = controller; } public PageReference doPDF() { return pageRef; } }
The above lets a user select records in a list view then is sent to the above VF page to "mass" handle the selected records from the view. As you can see is that I have a "commandButton" on the pageBlock. This button should open a new window and generator a PDF document based on the list of records.
I just cannot understand how to do this, because opening a new window is easy, but how do I "pass" the records in context to the second window that would render the PDF?
Any advise would be appreciated.
Thanks
Peter
Hi ,
You just need to create the another visual force page with same controller and render it as pdf.
call that page in your doPDF mehod
eg-
pagerefrencre p = new pagerefrence(' ' +/apex/pdfpage);
Thanks
Shailu
Hi,
Thanks for the reply. I want the "PDF" to be generated in a new window without moving from the current page. E.g.
Landing Page -> Click "Print Button" -> Opens a Window with page that generates PDF. the user is still on the "orignal" page at this point.
Thanks
Peter
Hi,
I am not sure if this might be a good solution but you can surely give it a try.
On click of the command button, call a pagereference action from your controller, in the action method give the pagereference to the same page with a parameter like "pdf=true".
In your constructor, use a variable which checks for this parameter and if it is present, you can dynamically render your page as pdf with
<apex:page renderAs="{!someVariable}"..>
In your controller,
Constructor()
{
if(ApexPages.currentPage().getParameters().containsKey('pdf'))
someVariable = 'pdf';
}
Hi ,
You need to write a function in javascript to call that page
eg-
function DisplayPopup() {
testwindow= window.open ('/apex/pdfpage','width=800,height=600');
testwindow.moveTo(0,0);
testwindow.opener = window;
}
Thanks
Shailu
Hi,
@Vishal Let me play around with this idea. I might be able to get something to work..
Thanks
Peter
Hi,
@Shailu - How would the "popup page" be linked to the data?
Thanks
Peter
Hi ,
As I had already mentioned that use the same controller which you are using on the other page and render it as PDF.
Same data will be populated.
Thanks
Shailu
Hi,
@Shailu - I have updated my VF page to the following now
Then created a "test" second VF page for the popup location called (productionRequestPDFGenerator). The second page contains this
However the "selected" var on the PageBlockTable does not get the records from the first page. And it is using the same controller and extension?
Thanks
Peter
Hi ,
Are You bindig the selected records in the list in your controller side. if no
Than you need to create a list of allselected records in your contoller and display them on the pdf page
Thanks
shailu
Hi,
Not really, so I have the "extension" class to this now.
Then on the second page / popup ammended to this
Now the pop windows displays the following error:
Am I binding and calling it correctly?
Thanks
Peter Guest
hi,
try this..
Hi,
Thanks, but I am using the "StandardSetController" which is a List Controller, not a single record. Maybe I am just not understanding, but it looks like your code is for a single record.
Thanks
Peter Giest
Hi ,
Yes its only for single record ,i just gave you the example to show .
Please go through this link it will help you
http://www.salesforce.com/us/developer/docs/pages/Content/apex_pages_standardsetcontroller.htm
Thanks
Shailu
Hi,
I ended up going with 2 visualforce pages. The first uses a commandLink that opens a second page with the list of ID's on the URL, then I run a second query to get the records.
Thanks
Peter