• nandy.33
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

 

<apex:page Controller="MyApp" >
    <!-- Begin Default Content REMOVE THIS -->
    <h1>Congratulations</h1>
  This is your new Page: MyApp
  <!-- End Default Content REMOVE THIS -->
    <apex:form >
        <apex:pageBlock id="thePageBlock">
            Select User:<apex:inputfield value="{!myOpportunity.accountid}"/>              
              <apex:commandButton value="Go!" title="Query" action="{!Query}"/>
        </apex:pageBlock>
        <apex:inputfield value="{!accounts.industry}"/>
        <apex:inputfield value="{!contact.LeadSource }"/>
    </apex:form>
</apex:page>

 

 

 

 

 

public class MyApp {

    public Opportunity myOpportunity  {
       get {
          if (myOpportunity  == null)
             myOpportunity  = new Opportunity ();
          return myOpportunity;
       }
       set;
    }
    
    public Account accounts{
       get {
          if (accounts== null)
             accounts= new Account ();
          return accounts;
       }
       set;
    }
    
    public Contact contact{
       get {
          if (contact== null)
             contact= new Contact ();
          return contact;
       }
       set;
    }
    
    public PageReference Query()
    {
    }
}

 

 

When I use this code,   it will alert me.

 

Error: Could not resolve the entity from <apex:inputField> value binding '{!accounts.industry}'. inputField can only be used with SObject fields.

 

but if I delete 

  <apex:inputfield value="{!accounts.industry}"/>

this code, everything is ok.    why?