So I have a custom object called Transactions, and have recently made a list view button that will redirect the user to a visualforce page that will show the selected record, and provide a few buttons to allow the user to select different report types to create. These reports I will be using visualforce pages as well, and have run into an issue when trying to use the same custom controller.
The first visualforce page is called LCD_Report_Selection and uses a custom controller LCD_Report_Selection_Controller. The basic page and controller I have made so far is as follows ***ignore the registry part, was a potential solution I found online that was not working **** :
<apex:page standardController="LCD_Transaction__c" extensions="LCD_Report_Selection_Controller" recordSetVar="transactions">
<apex:pageBlock >
<apex:pageBlockTable value="{!selected}" var="trans">
<apex:column value="{!trans.id}"/>
<apex:column value="{!trans.Transaction_Name__c}"/>
<apex:column value="{!trans.Issuer_Name__c}"/>
</apex:pageBlockTable>
<div align="center">
<apex:form >
<table>
<tr>
<td>
<apex:commandButton value="Pipeline Report" />
</td>
<td>
<apex:commandButton value="Broad Pipeline Report" action="{!Broad_Pipeline}" />
</td>
</tr>
<tr>
<td>
<apex:commandButton value="Long Comps Output" />
</td>
<td>
<apex:commandButton value="Long Comps Output by Tranche" />
</td>
</tr>
</table>
</apex:form>
</div>
</apex:pageBlock>
public class LCD_Report_Selection_Controller {
public List<LCD_Transaction__c> transactions {get;set;}
private Registry r;
public LCD_Report_Selection_Controller(ApexPages.StandardSetController controller){
List<LCD_Transaction__c> transactions = New List<LCD_Transaction__c>();
transactions = controller.getSelected();
saveTransactions(transactions);
r = Registry.instance();
r.add(LCD_Report_Selection_Controller.class, this);
system.debug('transactions --- ' + transactions);
system.debug('std set controller');
}
public void saveTransactions(List<LCD_Transaction__c> trans){
transactions = trans;
}
public PageReference Broad_Pipeline(){
PageReference report = Page.LCD_Broad_Pipeline_Report;
report.setRedirect(true);
return report;
}
}
What I am trying to achieve is when I press the broad pipeline report button, I would like to take the selected records and process them in a table on a seperate visualforce page. The issue I am running into is that since both pages use the same controller, when the second page is rendered it creates a new controller and does not have the selected transactions. I am attempting to create a second controller extension and pass a list of transactions to it, but have not been successful. What would be the best way to go about passing the transactions to the second visual forcepage? see below
<apex:page standardController="LCD_Transaction__c" extensions="LCD_Report_Selection_Controller" recordSetVar="LCDtransactions" renderAs="pdf" >
<apex:pageBlock>
<apex:pageBlockSection>
<apex:pageBlockTable value="{!transactions}" var="trans">
<apex:column value="{!trans.TransBreakDate__c}"/>
<apex:column value="{!trans.Issuer_Name__c}" />
<apex:column value="{!trans.TransSponsorName__c}" />
<apex:column value="{!trans.Issuer_Industry__c}" />
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>