Controller Class --> wrapperClassController
public class wrapperClassController
{
public wrapperClassController(ApexPages.StandardController controller){}
public List<wrapperContact> con;
public Contact cont;
public void setWrapperContact(List<wrapperContact> wc)
{
con= wc; }
public List<wrapperContact> getWrapperContact()
{
return con;
}
public List<wrapperContact> getContacts()
{
if(con == null)
{
con = new List<wrapperContact>();
for(Contact c : [select Id,Name,Email,Phone from Contact limit 10])
{
con.add(new wrapperContact(c));
}
}
return con;
}
public PageReference processSelected()
{
List<Contact> selectedContacts = new List<Contact>();
for(wrapperContact cCon: getContacts()) {
if(cCon.selected == true) {
selectedContacts.add(cCon.cont);
}}
System.debug('These are the selected Contacts...');
for(Contact selcon: selectedContacts) {
system.debug(selcon);
con=null;
}
return null;
}
public class wrapperContact
{
public Contact cont;
public Boolean selected;
public void setContact(Contact c)
{cont = c;}
public Contact getContact()
{return cont;}
public void setselected(Boolean s)
{ selected = s;}
public Boolean getselected()
{ return selected;}
public wrapperContact(Contact c)
{ cont = c; selected = false ; }
}
}
VF Page :-
<apex:page StandardController="Contact" extensions="wrapperClassController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table"/>
</apex:pageBlockButtons>
<!-- In our table we are displaying the cContact records -->
<apex:pageBlockTable value="{!contacts}" var="c" id="table">
<apex:column >
<!-- This is our selected Boolean property in our wrapper class -->
<apex:inputCheckbox value="{!c.selected}" />
</apex:column>
<!-- This is how we access the contact values within our cContact container/wrapper -->
<apex:column value="{!c.cont.Name}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
In the above vf page, i am trying to access wrapper class object in column value but when i do i am getting Error: Unknown property 'wrapperClassController.wrapperContact.cont'
but my getter method is public only ..dunno why i am getting this unknown property error ?
Thanks in advance,
Dinesh Kumar.