• Developer M
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

How do I rerender a StandardSetController? I've seen these posts indicating that I should requery the query locator, but I can't determine how to trigger the requery upon rerender, as I assumed that would happen automatically upon rerender.

http://community.salesforce.com/t5/Apex-Code-Development/Reload-StandardSetController-Records/m-p/193333

http://community.salesforce.com/t5/Visualforce-Development/Rerender-problem/td-p/173007

 

 

I'm not sure how to "make StandardSetController a property and re-initialize it".

 

My not working code:

 

 

<apex:page controller="testGetter">
<apex:pageblock>
<apex:form>
<APex:pageblocksection>
<apex:selectList value="{!inputBox}" size="1" title="Object List">
<apex:selectOptions value="{!rObjectsInUse}"></apex:selectOptions>
</apex:selectList>
<apex:commandButton rerender="preview" value="click me"> //when clicked, this should rerender the pageblocktable, but doesn't
</apex:commandbutton>
</apex:pageblocksection>
</apex:form>
</apex:pageBlock>

<apex:pageblock>

<apex:pageBlockSection id="preview">
<apex:outputtext value="{!inputbox}"/>
<br/>
<apex:pageBlockTable value="{!sRecords}" var="r"> //Doesn't rerender
<apex:column value="{!r.Id}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:page>

 

public with sharing class testGetter {

public String inputBox { get
{
system.debug('input box is: '+inputBox);
if(inputbox==null){
inputbox='Account';
}
return inputBox;
}

set; }

public List<SelectOption> getrObjectsInUse(){
List<SelectOption> options = new List<SelectOption>();
// AggregateResult[] ars=[SELECT objectName__c name1 FROM Replacer__c WHERE objectName__c!=null AND Active__c=True GROUP BY objectName__c];

// if(ars.size()>0){
// for (AggregateResult ar:ars){//for 1
// String objectName=String.valueof(ar.get('name1'));
options.add(new selectOption('Account','Account'));
options.add(new selectOption('Contact','Contact'));
options.add(new selectOption('Lead','Lead'));
// }//for 1
// }//if 1
return options;
}

public String recordQuerySQL(){
String recordQuerySQL = 'SELECT Id FROM '+inputBox;
system.debug('ObjectName :'+inputBox);
//make this query logic dynamic based on:
//1) Object
//2) Fields in the rules
//3) Records that meet the "find" criteria
return recordQuerySQL;
}//recordQuerySQL

public ApexPages.StandardSetController setCon{
get {
if(setCon==null){
String query = recordQuerySQL();
setCon = new ApexPages.StandardSetController(Database.getQueryL ocator(query));//how do I update this query for the set controller upon button click, which rerenders the PageBlockTable?
}
return setCon;
}//get
private set;
}//sRecords
public List<sObject> getsRecords() {
return (List<sObject>) setCon.getRecords();
}
}