+ Start a Discussion
mikefitzmikefitz 

Passing Arguments into a Controller for a Repeater in a Visualforce Page

I'm trying to display records segregated by recordtype

I seem to be pulling the recortype correctly and I have the repeat working but I can't  figure out how to pass the argument from the VF page into the controller.

I've tried passing an argument such as CasebyRT(rt.name) but it's not working and I can't get a param to work because it appears you can only pull one parameter at a time through the pagereference get method.

 

Any help would be appreciated. I was using this for a custom object but I changed it for cases so anybody can just copy the code below and see what I'm talking about.

 

Basically, I just want to dynamically pull records based on the recordtype in a repeat. If anybody has other thoughts, my ears are open.

 

This should work in anybody's org that has cases available.

 

Visualforce

 

<apex:page controller="DynamicRT">
  <apex:repeat value="{!CaseRT}" var="rt" >
        <apex:pageBlock title="Featured {!rt.name} Cases">
               <apex:pageBlockTable value="{!CasebyRT}" var="c">
                    <apex:column style="width:15%;" value="{!c.id}"/>
                </apex:pageBlockTable>
        </apex:pageBlock>
</apex:repeat>
</apex:page>

 

 

Apex

 

Public class DynamicRT{
public string CaseRType{ get; set; }

Public  List<Schema.RecordTypeInfo> getCaseRT(){
            Schema.DescribeSObjectResult R = Case.SObjectType.getDescribe();
            List<Schema.RecordTypeInfo> RT = R.getRecordTypeInfos();
        return RT;
    }

public list<Case> getCasebyRT() { 
        return [Select c.id
                From Case c 
                where c.RecordType.Name=:CaseRType];
    } 

}

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
mikefitzmikefitz

Resolved it myself.

I ended up using a component and passing in attributes to dynamically query the database.

 

Psuedo code

<VF PAGE>
<REPEAT Recordtype>

     <COMPONENT Recordtype="RT.name">

</REPEAT>

</VF PAGE>