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

Passing List from VF Page to another VF Page



I have a controller class and a VF page that display a list of records from which a user can select any number of records. Once a user check marks the records, they are displayed in second section of VF page.


Now again on second VF page (PDF page), I want to display the list again with extra information. But that list is not getting carried forward from one page to another.


Please suggest me as to what shall be done.






Thanks for the reply. I did read the post earlier but couldn't fix my issue.


I have followed this link to get list of records and when user selects the records, they get stored in a list.


If I write System.debug() to print the selected list in constructor, it prints.... () ....empty wrapperclass list.


Why I am not able to fetch the selectedList from another method into the constructor?

Ritesh AswaneyRitesh Aswaney

It seems like a wizard. Sharing the same controller between the two pages simplifies things quite a bit - are you using a common controller?

This post resolves an issue very simiar to yours - have a read.


I am using the same controller. I am still not able to fix the issue.


public class ControllerClass {
	public String currentPageId{get;set;}
	public List<orderWrapper> orderListWrapper{get;set;}
	public Order__c orderObj{get;set;}
    public String parId{get;set;}
    public List<Order__c> selectedOrders{get;set;}
    public List<MultiOrderWrapperClass> multiOrderList{get;set;}
	public ControllerClass(){
	currentPageId = ApexPages.currentPage().getParameters().get('id');
	orderListWrapper = new List<orderWrapper>();
    selectedOrders = new List<Order__c>();
    multiOrderList = new List<MultiOrderWrapperClass>();
	public List<orderWrapper> getOrders(){
        for(Order__c o : [Select Name From Order where *somecondition*])
                orderListWrapper.add(new orderWrapper(o));
        return orderListWrapper;
	public PageReference getSelected(){
        for(OrderWrapper ordWrapper : orderListWrapper)
        if(ordWrapper.selected == true)
        return null;
public PageReference init(){
		multiOrderList = new List<MultiOrderWrapperClass>();
        Order__c orderObj = [Select Name from Order__c where id=: currentPageId];
        List<Id> selectedOrderIds = new List<Id>();
        for(Integer i=0; i<selectedOrders.size();i++ ){selectedOrderIds.add(selectedOrders[i].id);}
        for(Order obj : [Select Name from Order where id IN : selectedOrderIds]){
        		MultiOrderWrapperClass mOrderObj = new MultiOrderWrapperClass(obj);
        PageReference pdf = Page.SecondVFPage;
		Datetime temp = Datetime.newInstance(,,;
        Attachment attach = new Attachment();
        blob body;
            body = pdf.getcontent();
        catch (visualforceexception e)
            body = blob.valueof('some text');    // This is used to pass unit test criteria
       attach.body = body; = 'Name'; 
        attach.isprivate = false;
        attach.parentid = currentPageId;
        insert attach;
        return new PageReference('/'+currentPageId);
	public PageReference cancel(){
	return new PageReference('/'+currentPageId);

	public class OrderWrapper{
		public Order__c ord{get; set;}
		public Boolean selected {get; set;}
		public orderWrapper(Order o){
            ord = o;
            selected = false;
	public class MultiOrderWrapperClass{
		public String name{get;set;}
		public MultiOrderWrapperClass(Order Obj){ = Obj.Name;


First VF Page
<apex:page controller="Creative_MultipleOrderLine" sidebar="false"> 
	<apex:form >
		<apex:pageBlock title="Parent : {!parId}">
 			<apex:pageBlockButtons >
    			<apex:commandButton value="Generate Order" action="{!init}"/>
    			<apex:commandButton value="Cancel" action="{!cancel}"/>
 			<apex:pageBlockSection title="Related Order List">
 				<apex:dataTable value="{!orders}" var="o" columnswidth="50px,50px" cellpadding="4" border="1">
 				<apex:column >
 				<apex:facet name="header">
 				<!--<apex:inputCheckbox onclick="{!selectedOrders}">
 					  <apex:actionSupport event="onclick" action="{!getSelected}" onsubmit="checkAll(this)" rerender="Selected_ORD"/>
			 	<apex:inputCheckbox value="{!o.selected}" id="checkedone">
					  <apex:actionSupport event="onclick" action="{!getSelected}" rerender="Selected_ORD"/>
				<apex:column headervalue="Order ID" value="{!o.ord.Name}" />
			<apex:pageBlockSection Title="Selected Order List" id="Selected_ORD">
			<apex:dataTable value="{!SelectedOrders}" var="s" columnswidth="50px,50px" cellpadding="4" border="1">
			<apex:column headervalue="Order ID" value="{!s.Name}" />

SecondVF Page
<apex:page controller="Creative_MultipleOrderLine" showheader="false" renderas="pdf"> 
View {!multiOrderList} View