I'm trying to separate my Visualforce table by Hummer's Id
value:
public List<Hammer__c> getHummers() {
return [SELECT Id, Name FROM Hammer__c];
}
public List<Factory__c> getFactories() {
List<Hammer__c> hummers = getHummers();
List<Factory__c> factories;
for(Hammer__c h : hummers){
factories = [SELECT Name FROM Factory__c WHERE Hammer__c =: h.Id];
}
return factories;
}
VF:
<apex:repeat value="{!hummers}" var="h" >
<apex:pageBlock title="{!h.Name}">
<apex:pageBlockTable value="{!factories}" var="f" border="1px" width="100%">
<apex:column value="{!f.Name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:repeat>
But of caurse I get only the last Factory List (after return factories
) with the same values:
How can I fix it to get values for each Hummer?