I have a custom visualforce component with a controller, it takes an attribute of an Id of a related record, and in the controller I query for the set of objects I want to display.
When I attempt to dereference this list inside an <apex:repeat /> tag I get some strange behavior. Am I totally missing something?
Controller:
public without sharing class VIPCommissionProgramAtSitesController {
public Id accreditationStandardId {get; set {
accreditationStandardId = value;
linkedServiceStandardLocations = [SELECT Id, Program_At_Site__r.Program__r.Name, Program_At_Site__r.Site__r.Name,
Service_Standard__r.Service_Standard__c, Accreditation_Standard__c, Program_At_Site__c
FROM Linked_Service_Standard_Location__c WHERE Accreditation_Standard__c = :accreditationStandardId];
System.debug(LoggingLevel.WARN,'Selecting LSSL: '+linkedServiceStandardLocations.size());
}
}
public List<Linked_Service_Standard_Location__c> linkedServiceStandardLocations {get; private set; }
// The service standard locations to which this AC_Standard__c IS linked
public Map<Id, Boolean> appliesToLinkedServiceStandardLocation {get {
Map<Id, Boolean> retVal = new Map<Id, Boolean>();
for (Linked_Service_Standard_Location__c lssl : linkedServiceStandardLocations) {
retVal.put(lssl.id, false);
}
return retVal;
} set;
}
}
Component:
<apex:component controller="SitesController" allowDml="true">
<apex:attribute name="stdid" type="String" required="true" assignTo="{!standardId}" description="description" />
<apex:repeat value="{!locations}" var="lssl">
<apex:outputText value="{!lssl.Id}" />
</apex:repeat>
</component>
The output repeat is empty?
However, when I output some text inside of the repeat I get repeated statements:
<apex:component controller="VIPCommissionProgramAtSitesController" allowDml="true">
<apex:attribute name="acStandardId" type="Id" assignTo="{!accreditationStandardId}" description="id of the accreditation cycle to render linked program at sites for" />
<apex:attribute name="accreditationStandardTitle" type="String" description="description" />
<div class="modal-content" id="{!accreditationStandardId}-modal">
<div class="modal-header">
<h1>{!accreditationStandardTitle}</h1>
</div>
<div style="min-height:500px; margin-top:45px;">
<div>
<h3>Please provide a <strong>Site Visit Justification</strong> for this rating.</h3>
</div>
<div class="coa-tabs-wrapper">
<ul class="coa-tabs">
<li class="coa-tab coa-modal-tab active">
<a href="#view-by-programs-{!accreditationStandardId}">View by Programs</a>
</li>
<li class="coa-tab coa-modal-tab">
<a href="#view-by-sites-{!accreditationStandardId}">View by Sites</a>
</li>
</ul>
<div class="coa-tabs-pane-wrapper">
<div id="view-by-programs-{!accreditationStandardId}" class="coa-tabs-pane active">
{!accreditationStandardId}
{!appliesToLinkedServiceStandardLocation}
<apex:repeat value="{!linkedServiceStandardLocations}" var="lssl">
<apex:outputText value="{!lssl.Id}" />
</apex:dataTable>
</div>
<div id="view-by-sites-{!accreditationStandardId}" class="coa-tabs-pane">
</div>
</div>
</div>
</div>
<div class="modal-footer" style="height: auto; padding: 20px 0;">
</div>
</div>
</apex:component>
I've checked field accessibility on all of these fields, and the object, no problem there.
Update, I've posted a complete version of my controller / component as this is really confounding me!
In the debug log, I've confirmed that linkedServiceStandardLocations does infact return 7 results, and also by outputting the 'Map' of the list, appliesToLinkedServiceStandardLocation, shows 7 text values. However, when I attempt to do:
{!linkedServiceStandardLocations} anywhere on the component, the whole page crashes.
standardIdsetter? I've had better luck with that approach.public String standardId { get; set { locations = /*query*/; standardId = value; } public List<MyObject__c> records { get; private set; }stringthe data is correct but VF merge fields don't work!? When I return it as a list I can't get merge fields to work and attempting to just render the list redirect the whole page crashes!ID, notStringalthough that isn't the cause of the issue here. (2) Since this is aSitescontroller, then I would surmise that the site'sguest userdoesn't have visibility to the custom object'sIDfield .