+ Start a Discussion

Apex:Inputfield with custom controller





I am trying to get two values from the user input .  I am getting error as 


<apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.







public class  AdditionController
  public integer A;
  public integer B;
  public AdditionController addctl{get;set;}
  public integer getA()
     return this.A;
  public void setA(integer val)
  public integer getB()
     return this.B;
  public void setB(integer val)



VF Page


<apex:page controller="AdditionController">
    <apex:form >
        <apex:inputField id="A" value="{!addctl.A}"/>
        <apex:inputField id="B" value="{!addctl.B}"/>






<apex:inputField> can only be used with SObjects.

for example you can use like this <apex:inputField value="{!Account.Name}">

But for you requirement use  <apex:inputText>


Yoganand GadekarYoganand Gadekar

Inputfield should be binded to a field of object only.


for example


account a = new account ();


<apex:inputfield value="{!a.name}"/>


Hit kudos and mark as answer if it helps you.



Abhijit ThoteAbhijit Thote
If it's not an sObject field, you have to use one of the typed input tags. In your case, you would use <apex:inputText> instead of using <apex:inputField>

Additional options include <apex:inputcheckbox and <apex:inputTextArea> to handle other data types.