You need to sign in to do that
Don't have an account?
1542VeMan
pageBlockTable not rendering in page
This is probably an easy solution, but its really frustrating:
The page is using a selectList to provide a value to the query in the controller. The query results should be displayed in a pageBlockTable, but the table isn't rendering when the commandButton is pushed.
I'm pretty sure the select value is being set, and the query is firing as expected, but I can't figure out ahy the table isn't rendering: Here is the code:
public with sharing class CompController { public list<string> compNames {get; set;} public list<Comp__c> comps; public list<SelectOption> compList; public id selectedComp {get; set;} public CompController() { comps = new list<Comp__c>([select id, Name from Comp__c]); compList = getCompList(); } public list<SelectOption> getCompList() { compNames = new list<string>(); compList = new list<SelectOption>(); for (Comp__c Comp :comps) { system.debug(Comp.Name); compNames.add(Comp.Name); compList.add(new SelectOption(Comp.id, Comp.Name)); } return compList; } public list<Comp_Control__c> Controls; public list<Comp_Control__c> getControls() { return Controls; } public list<Comp_Control__c> setControls(id CID){ Controls = new list<Comp_Control__c> ([select id, Control__c, Control_Category__c,
Control_Number__c
from Comp_Control__c where Comp__c = :CID]);
return Controls; } public pageReference fetchControls() { setControls(selectedComp); return null; } }
The page is here:
<apex:page controller="ComplianceController"> <apex:form > <apex:pageBlock title="Compliance Control Check"> Select Compliance <p/> <apex:SelectList value="{!selectedComp}" > <apex:SelectOptions value="{!CompList}"/> </apex:SelectList> <apex:commandButton value="Fetch Controls" action="{!fetchControls}" reRender="CompControls"/> <p/><p/> <apex:outputPanel id="CompControls"> <apex:pageBlockTable value="{!Controls}" var="C"> <apex:column > <apex:outputLink value="/{!C.Control__c}">{!C.Control__r.Name} </apex:outputLink> </apex:column> <apex:column value="{!C.Control_Number__c}"/> <apex:column value="{!C.Control_Category__c}"/> </apex:pageBlockTable> </apex:outputPanel> </apex:pageBlock> </apex:form> </apex:page>
Any feedback is appreciated
I suspect the issue is your setControlls method.
For a property (controls) to be available to a visualforce page there must be a public getter and setter. The setter syntax would need to be :
as you have a setControls where the signature doesn't that expected for a setter, I don't think your controls property will be available to the page.
Try changing the name of setControls to populateControls (and the line where you call it from the fetchControls method).