0

I wonder, how can I pass input variable to getValuesForRepeat in apex:repeat please. I.e, my apex:repeat renders different contents depends on inputVar1. Basically,

  1. <apex:repeat value="{!valuesToBind}" var="valueToBind"> binds to getValuesToBind() in the controller.
  2. getValuesToBind() retrieve inputVar1 value from the controller constructor with inputVar1. ----> This value was not updated.

======> How can I get something like getValuesToBind(inputVar1) or bind from visual force component please? <apex:repeat value="{!valuesToBind}" var="valueToBind" inputParam="someVariable">

In my controller

public class controllerClass {

    public String inputVar1;
    List<Object1> valuesForRepeat;  

    public controllerClass() {
    }
    public controllerClass(String inputVar1) {
        setInputVar1(inputVar1);
    }

    public void setInputVar1(String inputVar1) {
        this.inputVar1 = inputVar1;
    }
    public String getInputVar1() {
        return this.inputVar1;
    }

    public List<Object1> getValuesToBind(){

        Object2 obj = [SELECT blabla FROM Object2 where field =:***this.inputVar1*** Limit 1]; //HERE!!!!!!
        valuesForRepeat = [SELECT field1, field2, blabla FROM Object1 where Id in :Object1Ids];
        return valuesForRepeat;
    }
}

In visual force component

<apex:component controller="controllerClass" access="global">
    <apex:attribute name="templateBoundField" type="String" description="blabla" assignTo="{!inputVar1}" />
    <apex:outputPanel rendered="{!!valuesToBind.empty}">
        <apex:repeat value="{!valuesToBind}" var="valueToBind">
            <table >
                <table >
                    <tr><td ">{!valueToBind.field1}</span></td></tr>
                </table>
            </table>    
        </apex:repeat>
    </apex:outputPanel>
    <apex:outputPanel rendered="{!valuesToBind.empty}">
        <p >
            No New ValuesToBind to Report.
        </p>
    </apex:outputPanel>
</apex:component>

1 Answer 1

0

You've made this too complicated

Component controller

public class controllerClass {

    public String inputVar1 {get; set;}

    public controllerClass() {}

    public List<Object1> getValuesToBind(){

        Object2 obj = [SELECT ... FROM Object2 where field =:this.inputVar1 Limit 1]; 
        return obj != null 
             ? [SELECT field1, ... 
                   FROM Object1 WHERE Id in :obj.Id]
             : new List<Object1>();
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .