+ Start a Discussion
Karthik ManoKarthik Mano 

Wrapper class with sobject

Hi . In my vf page i am getting an error like  " Unknown property 'SObject.name' "

Controller :

List<Account> accList=new List<Account>([SELECT Name,ID,owner.name FROM Account]);

public List<objectwrapper> getavailableObjects() {

if(selected_object=='ACCOUNT') {
for(Account a:accList) {
wrapperList.add(new objectwrapper(a));
SelectObject();
}
}
return wrapperList;
}

public class objectwrapper  {
public sObject Objectwrap{get;set;}
public boolean selected {get;set;}
public objectwrapper(sObject sob)
{
Objectwrap=sob;
selected=false;
}

}

vf page :

<apex:pageBlockTable value="{!availableObjects}" var="obj">

<apex:column >
<apex:inputCheckbox value="{!obj.selected}" id="checkeddone">
<apex:actionSupport event="onclick" action="{!GetSelected}" reRender="Sel_OBJ"/>

</apex:inputCheckbox></apex:column>

<apex:column headerValue="Name" value="{!obj.Objectwrap.name}"/>
<apex:column headerValue="ID" value="{!obj.Objectwrap.Id}"/>
<apex:column headerValue="Owner" value="{!obj.Objectwrap.Owner.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>

 
Can anyone please help. I am struck up with this. Thanks in advance !!

Srinu@dreamsSrinu@dreams

Refer the following link it will be helpful for you:

http://wiki.developerforce.com/page/Wrapper_Class

Arun Kumar 76Arun Kumar 76
use
<apex:column headervalue="Name" value="{!obj.Objectwrap['name']}"/>
instead of

<apex:column headerValue="Name" value="{!obj.Objectwrap.name}"/>