I have a custom controller and VF page. I'm trying to set up the page to render sections based upon the value of a field on the OpportunityLineItem object. However, I'm not quote sure how to get the variable to use in the Rendered component from the controller list over to my VF page.
Controller:
String oliId;
public list<OpportunityLineItem> listOLI{get;set;}
public CalculateOLISummary() {
oliId = ApexPages.currentPage().getParameters().get('id');
}
public void init(){
listOLI = new list<OpportunityLineItem>();
listOLI = [SELECT OpportunityId, Grouping__c, Product2.Name, ProductCode, Quantity, UnitPrice,
TotalPrice, Discount, ListPrice
FROM OpportunityLineItem
WHERE OpportunityId =:oliId];
public PageReference Cancel(){
PageReference pg = new PageReference('/' + oliId);
return pg;
}
}
VF Page:
<apex:page controller="CalculateOLISummary" action="{!init}" >
<apex:pageMessages id="pgMess" />
<apex:form id="frmReview" >
<apex:pageBlock id="pgBlckQSummary" title="OLI Summary">
<center><apex:commandButton title="Back to OPP" value="Back to Opp" action="{!cancel}"/></center>
<!-- I ONLY WANT THIS pageBlockTable to render records in my list where the Grouping__c value is TRUE -->
<apex:pageBlockTable title="Quote Summary" value="{!listOLI}" var="OLI">
<apex:column headerValue="Product">
<apex:outputField value="OLI.Product2"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
listOLIis a list ofOpportunityLineItemrecords. So in that caselistOLI.Grouping__c == TRUEshouldn't even compile. And that's because your conditional statement assumes thatlistOLIis a record instead of a list itself. Are you able to save your VF page at the first place?