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
ArjunmcaArjunmca 

Apex:Inputfield with custom controller

 

 

HI,

 

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.

 

 

 

Controller

---------------

 

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)
  {
      this.A=val;
  }
  
  public integer getB()
  {
     return this.B;
  }
  
  public void setB(integer val)
  {
      this.B=val;
  }
   
 
}

 

 

VF Page

---------------

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

</apex:page>

 

 

Thanks.

asish1989asish1989

<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.

 

Thanks

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.