Visualforce Page:
<apex:page controller="wrappercls" >
<Apex:form >
<apex:pageBlock >
<script>
alert('{!items}');
</script>
<apex:repeat value="{!items}" var="i">
<script>
alert('{!i.name}');
alert('{!i.salary}');
</script>
</apex:repeat>
<apex:PageBlockTable value="{!items}" var="i">
<apex:column value="{!i.name}"/>
<apex:column value="{!i.salary}"/>
</apex:PageBlockTable>
</apex:pageBlock>
</Apex:form>
</apex:page>
Apex Class:
public with sharing class wrappercls {
public class wrapper{
public string name {get; set;}
public integer salary {get; set;}
public wrapper(string s, integer i){
name=s;
salary=i;
}
}
public LIst<Wrapper> items{get; set;}
public wrappercls(){
items= new List<wrapper>();
items.add(new wrapper('Charan',5000));
items.add(new wrapper('Ravi',3000));
items.add(new wrapper('Hari',4000));
}
/*
List<wrapper> lstwrap = new List<wrapper>();
public List<wrapper> getitems(){
lstwrap.add(new wrapper('Charan',5000));
lstwrap.add(new wrapper('Ravi',3000));
lstwrap.add(new wrapper('Hari',4000));
return lstwrap;
}
Note: while using this comment lines 13 to 19
*/
}
No comments:
Post a Comment