You need to sign in to do that
Don't have an account?
Uday Menkurkar
Can you have multiple instantiations of StandardController??
Is it possible to have multiple instantiations of a StandardController? For example, in a VF page below I would like to display two types of lists. Deals which with "High Likelihood" and deals with "Low Likelihood". And for each Deal I'm also displaying associated child records. Currently I've only one query in the extension controller "extCon". What I would like to do is split the query into two queries so I can add a WHERE clause to both and show two separate page blocks in the same page. Is it possible to have two separate controller instantiations? Or, is there better way to accomlish the same task??
<!-- Visualforce code -->
<apex:page standardController="PP_Deals__c" recordSetVar="deals" extensions="extCon">
<font size="5" color="blue"> <b> Private Placement - Active Deal Log1 </b> </font>
<apex:pageBlock title="Higher Chance">
<apex:pageBlockTable value="{! deals }" var="ds">
<apex:column value="{! ds.Issuer__c }"/>
<apex:column headerValue="Bids Due" value="{! ds.Circle_Due_Date__c }"/>
<apex:column headerValue="Maturities">
<apex:pageBlockTable value="{!ds.Tranches__r}" var="val">
<apex:column headerValue="Tenor" value="{! val.name }"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock title="Lower Chance">
<apex:pageBlockTable value="{! deals }" var="ds">
<apex:column value="{! ds.Issuer__c }"/>
<apex:column headerValue="Bids Due" value="{! ds.Circle_Due_Date__c }"/>
<apex:column headerValue="Maturities">
<apex:pageBlockTable value="{!ds.Tranches__r}" var="val">
<apex:column headerValue="Tenor" value="{! val.name }"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
And, here is the extension controller code. Here I'm wondering if it is possible to have two separate initiations so I can add a WHERE clause?? And, if yes, how to call two separate initiations in VF above??
public class extCon {
private final PP_Deals__c deal;
public extCon(ApexPages.StandardSetController controller) {
controller = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Id, Name FROM PP_Deals__c]));
}
}
Thanks
<!-- Visualforce code -->
<apex:page standardController="PP_Deals__c" recordSetVar="deals" extensions="extCon">
<font size="5" color="blue"> <b> Private Placement - Active Deal Log1 </b> </font>
<apex:pageBlock title="Higher Chance">
<apex:pageBlockTable value="{! deals }" var="ds">
<apex:column value="{! ds.Issuer__c }"/>
<apex:column headerValue="Bids Due" value="{! ds.Circle_Due_Date__c }"/>
<apex:column headerValue="Maturities">
<apex:pageBlockTable value="{!ds.Tranches__r}" var="val">
<apex:column headerValue="Tenor" value="{! val.name }"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock title="Lower Chance">
<apex:pageBlockTable value="{! deals }" var="ds">
<apex:column value="{! ds.Issuer__c }"/>
<apex:column headerValue="Bids Due" value="{! ds.Circle_Due_Date__c }"/>
<apex:column headerValue="Maturities">
<apex:pageBlockTable value="{!ds.Tranches__r}" var="val">
<apex:column headerValue="Tenor" value="{! val.name }"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
And, here is the extension controller code. Here I'm wondering if it is possible to have two separate initiations so I can add a WHERE clause?? And, if yes, how to call two separate initiations in VF above??
public class extCon {
private final PP_Deals__c deal;
public extCon(ApexPages.StandardSetController controller) {
controller = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Id, Name FROM PP_Deals__c]));
}
}
Thanks
<pre>
public class DealController
{
public DealController()
{
// nothing to do here
}
// use whatever parameters you need to filter the query properly
private List<PP_Deals__c> queryDeals( String likelihood )
{
return
[ SELECT Id, Issuer__c, Circle_Due_Date__c,
( SELECT Id, Name
FROM Tranches__r
)
FROM PP_Deals__c
WHERE Likelihood__c = :likelihood
];
}
public List<PP_Deals__c> highLikelihoodDeals
{
get
{
if ( highLikelihoodDeals == null )
{
highLikelihoodDeals = queryDeals( 'High Likelihood' );
}
return highLikelihoodDeals;
}
private set;
}
public List<PP_Deals__c> lowLikelihoodDeals
{
get
{
if ( lowLikelihoodDeals == null )
{
lowLikelihoodDeals = queryDeals( 'Low Likelihood' );
}
return lowLikelihoodDeals;
}
private set;
}
}
<apex:page controller="DealController" >
<font size="5" color="blue"> <b> Private Placement - Active Deal Log1 </b> </font>
<apex:pageBlock title="Higher Chance">
<apex:pageBlockTable value="{! highLikelihoodDeals }" var="ds">
<apex:column value="{! ds.Issuer__c }"/>
<apex:column headerValue="Bids Due" value="{! ds.Circle_Due_Date__c }"/>
<apex:column headerValue="Maturities">
<apex:pageBlockTable value="{!ds.Tranches__r}" var="val">
<apex:column headerValue="Tenor" value="{! val.name }"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock title="Lower Chance">
<apex:pageBlockTable value="{! lowLikelihoodDeals }" var="ds">
<apex:column value="{! ds.Issuer__c }"/>
<apex:column headerValue="Bids Due" value="{! ds.Circle_Due_Date__c }"/>
<apex:column headerValue="Maturities">
<apex:pageBlockTable value="{!ds.Tranches__r}" var="val">
<apex:column headerValue="Tenor" value="{! val.name }"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
</pre>
All Answers
<pre>
public class DealController
{
public DealController()
{
// nothing to do here
}
// use whatever parameters you need to filter the query properly
private List<PP_Deals__c> queryDeals( String likelihood )
{
return
[ SELECT Id, Issuer__c, Circle_Due_Date__c,
( SELECT Id, Name
FROM Tranches__r
)
FROM PP_Deals__c
WHERE Likelihood__c = :likelihood
];
}
public List<PP_Deals__c> highLikelihoodDeals
{
get
{
if ( highLikelihoodDeals == null )
{
highLikelihoodDeals = queryDeals( 'High Likelihood' );
}
return highLikelihoodDeals;
}
private set;
}
public List<PP_Deals__c> lowLikelihoodDeals
{
get
{
if ( lowLikelihoodDeals == null )
{
lowLikelihoodDeals = queryDeals( 'Low Likelihood' );
}
return lowLikelihoodDeals;
}
private set;
}
}
<apex:page controller="DealController" >
<font size="5" color="blue"> <b> Private Placement - Active Deal Log1 </b> </font>
<apex:pageBlock title="Higher Chance">
<apex:pageBlockTable value="{! highLikelihoodDeals }" var="ds">
<apex:column value="{! ds.Issuer__c }"/>
<apex:column headerValue="Bids Due" value="{! ds.Circle_Due_Date__c }"/>
<apex:column headerValue="Maturities">
<apex:pageBlockTable value="{!ds.Tranches__r}" var="val">
<apex:column headerValue="Tenor" value="{! val.name }"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock title="Lower Chance">
<apex:pageBlockTable value="{! lowLikelihoodDeals }" var="ds">
<apex:column value="{! ds.Issuer__c }"/>
<apex:column headerValue="Bids Due" value="{! ds.Circle_Due_Date__c }"/>
<apex:column headerValue="Maturities">
<apex:pageBlockTable value="{!ds.Tranches__r}" var="val">
<apex:column headerValue="Tenor" value="{! val.name }"/>
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
</pre>