Let's say I want to iterate over a List of objects based on a class in my controller (myObject), and have a commandButton to display a pageblock within the apex:repeat.
<apex:repeat value="{!myObjects}" var='myObject'>
<apex:commandButton action="{!myObject.renderMe}" value="Show Pageblock" />
<apex:pageblock title="myTitle" rendered = "{!myObject.rendered}">
Here I am!
</apex:pageblock>
</repeat>
Controller excerpt:
List<myObject> myObjects;
public class myObject {
public Integer height {get;set;}
public Integer width {get;set;}
public Boolean rendered {get; set;}
public void renderMe(){
this.rendered = true;
}
public List<myObject> getmyObjects(){
List<myObject> tmpList = new List<myObject>();
myObject obj1 = new myObject();
obj1.height = 5;
obj1.width = 5;
obj1.rendered = false;
tmpList.add(obj1);
return tmpList;
}
}
When I click the commandButton, the pageblock is not rendering because {!myObject.rendered} is not being set to true. Why is this the case?
More generally, is storing the rendered property like this the right approach?
Thanks