0

Apex:

public class Display_Set {
    public string name {set;get;}
    public integer age {set;get;}

    public class Display_set_1 {
        public set<Display_Set>s1{set;get;}
        public set<Display_Set>temp{set;get;}
        public integer count {set;get;}
        public Display_Set_1(){
            s1=new set<Display_Set>();
            temp=new set<Display_Set>();
            Display_Set s2=new Display_Set();
            Display_Set s3=new Display_Set();
            Display_Set s4=new Display_Set();
            Display_Set s5=new Display_Set();
            s2.name='ravi';
            s2.age=10;
            s1.add(s2);
            s3.name='kotesh';
            s3.age=20;
            s1.add(s3);
            s4.name='vipin';
            s4.age=30;
            s1.add(s4);
            s5.name='guru';
            s5.age=40;
            s1.add(s5);
        }
        public void call(){
            integer i=0;
            for(Display_Set a:s1){
                if(i==count){
                    temp.clear();
                    temp.add(a);
                }
                i++;
            }
        }
    }
}

vf page:

<apex:page controller="Display_Set" >
          {!temp}
    <apex:form>
        <apex:inputText value="{!count}">
        <apex:commandButton value="call" action="{!call}"/>
        </apex:inputText>
    </apex:form>
</apex:page>
1
  • what are your trying to do with the line {!temp} (second line in your vf page)?
    – m Peixoto
    May 22, 2019 at 10:24

1 Answer 1

1

Your class Display_Set has only two properties:

public string name {set;get;}
public integer age {set;get;}

The {!temp} is not a property or method of your class Display_Set. The property temp is a property of the inner class.

It is the error reason.

If you want to continue to use inner class, you should do some like this:

public class Display_Set {
    public string name {set;get;}
    public integer age {set;get;}
    public Display_Set.Display_set_1 display_set_1 {set;get;}


public void Display_Set () {
    display_set_1 = new Display_Set.Display_set_1();
}

public class Display_set_1 {
    public set<Display_Set>s1{set;get;}
    public set<Display_Set>temp{set;get;}
    public integer count {set;get;}
    public Display_Set_1(){
        s1=new set<Display_Set>();
        temp=new set<Display_Set>();
        Display_Set s2=new Display_Set();
        Display_Set s3=new Display_Set();
        Display_Set s4=new Display_Set();
        Display_Set s5=new Display_Set();
        s2.name='ravi';
        s2.age=10;
        s1.add(s2);
        s3.name='kotesh';
        s3.age=20;
        s1.add(s3);
        s4.name='vipin';
        s4.age=30;
        s1.add(s4);
        s5.name='guru';
        s5.age=40;
        s1.add(s5);
    }
    public void call(){
        integer i=0;
        for(Display_Set a:s1){
            if(i==count){
                temp.clear();
                temp.add(a);
            }
            i++;
        }
    }
}
}

vf:

<apex:page controller="Display_Set" >
          {!display_set_1.temp}
    <apex:form>
        <apex:inputText value="{!display_set_1.count}">
        <apex:commandButton value="call" action="{!display_set_1.call}"/>
        </apex:inputText>
    </apex:form>
</apex:page>

You must log in to answer this question.

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