function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
siva sai 22siva sai 22 

Could not resolve the entity from <apex:inputField> value binding '{!Opportunities.Name}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.

Hi,
 i created an apex class in that one i want to add each Opportunity in to list of Opportunities but in vf page i am getting an error "Could not resolve the entity from <apex:inputField> value binding '{!Opportunities.Name}'.  <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable."
Here is my code :
Apex code::
public class Opportunity_List {
    public List<Opportunity> Opportunities {set;get;}
    public Opportunity Oppos {set;get;}
    public Opportunity_List(){
        Opportunities = new List<Opportunity>();
        Oppos = new Opportunity();
    }
    public void add(){
        Opportunities.add(Oppos);
       
    }
    public void cancel(){
        Opportunities.clear();
    }

}
VF Code::
<apex:page controller="Opportunity_List" >
    <apex:form>
    	<apex:pageBlock title="Opportunity">
            <apex:pageBlockButtons>
                	<apex:commandButton value="ADD" action="{!add}" />
                    <apex:commandButton value="Clear" action="{!cancel}" />
                </apex:pageBlockButtons>
        	<apex:pageBlockSection  >
                <apex:inputField value="{!Opportunities.Name}" />
                <apex:inputField value="{!Opportunities.LeadSource}" />
                <apex:inputField value="{!Opportunities.ExpectedRevenue}" />
                <apex:inputField value="{!Opportunities.NextStep}" />
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

could any one tell me that why it is comming like this..

Thanks and Regards
krishna
 

sfdcMonkey.comsfdcMonkey.com
HI Krishna ,
for resolve this error you have need to use <apex:repeat> tag.

use below code :
<apex:page controller="Opportunity_List" >
    <apex:form>
    	<apex:pageBlock title="Opportunity">
            <apex:pageBlockButtons>
                	<apex:commandButton value="ADD" action="{!add}" />
                    <apex:commandButton value="Clear" action="{!cancel}" />
                </apex:pageBlockButtons>
        	<apex:pageBlockSection  >
                <apex:repeat value="{!Opportunities}" var="o">
                 <apex:inputField value="{!o.Name}" />
                 <apex:inputField value="{!o.LeadSource}" />
                 <apex:inputField value="{!o.ExpectedRevenue}" />
                 <apex:inputField value="{!o.NextStep}" />
                </apex:repeat>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

i hope it helps you.
  Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks
http://sfdcmonkey.com
siva sai 22siva sai 22
Hi piyush_soni,
     User-added image

     using repeat tag i am unable to reslove this

Thanks & Regards
krishna
 
siva sai 22siva sai 22
Modified code please use this to modifie
Apex code::
public class Opportunity_List {
    public List<Opportunity> Opportunities {set;get;}
    public Opportunity Oppos {set;get;}
    public Opportunity_List(){
        Opportunities = new List<Opportunity>();
        Oppos = new Opportunity();
    }
    public void add(){
        Opportunities.add(Oppos);
       
    }
    public void cancel(){
        Opportunities.clear();
    }

}

VFPCode::
<apex:page controller="Opportunity_List" >
    <apex:form>
    	<apex:pageBlock title="Opportunity">
            <apex:pageBlockButtons>
                	<apex:commandButton value="ADD" action="{!add}" />
                    <apex:commandButton value="Clear" action="{!cancel}" />
                </apex:pageBlockButtons>
        	<apex:pageBlockSection  >
                <apex:inputField value="{!Oppos.Name}" />
                <apex:inputField value="{!Oppos.LeadSource}" />
                <apex:inputField value="{!Oppos.ExpectedRevenue}" />
                <apex:inputField value="{!Oppos.NextStep}" />
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Thanks & Regards
krishna
 
sfdcMonkey.comsfdcMonkey.com
use below code :
<apex:page controller="Opportunity_List" >
    <apex:form>
    	<apex:pageBlock title="Opportunity">
            <apex:pageBlockButtons>
                	<apex:commandButton value="ADD" action="{!add}" />
                    <apex:commandButton value="Clear" action="{!cancel}" />
                </apex:pageBlockButtons>
        	<apex:pageBlockSection  >
                <apex:repeat value="{!Opportunities}" var="o">
                  <apex:inputField value="{!o.Name}" />
                <apex:inputField value="{!o.LeadSource}" />
                <apex:inputField value="{!o.ExpectedRevenue}" />
                <apex:inputField value="{!o.NextStep}" />
                </apex:repeat>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class Opportunity_List {
    public List<Opportunity> Opportunities {set;get;}
    public Opportunity Oppos {set;get;}
    public Opportunity_List(){
        Opportunities = new List<Opportunity>();
        Oppos = new Opportunity();
        Opportunities.add(Oppos);
    }
    public void add(){
        system.debug('existing --> ' + Opportunities);
       Oppos = new Opportunity();
        Opportunities.add(Oppos);
       
    }
    public void cancel(){
        Opportunities.clear();
    }

}

i hope it helps you.
  Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks
http://sfdcmonkey.com