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
Nikhil M KumarNikhil M Kumar 

How do I bind the Inputfield in the Visualforce page to the Apex Class without using an sObject (standard or custom)?

Danish HodaDanish Hoda
Hi nikhil,
You can simply use 
public string str{get; set;}

and use {!str} in the vf page
Hi Nikhil,

Unfortunately, you can only use sObjects or object with inputfield, you cannot even use wrapper class object with inputfield.
One of the way to resolve your issue is to use the tags which are compatible like <apex:inputText>, <apex:inputTextArea>, that will work.

Check out below code sample.
<apex:page controller="CustomController">
    	<apex:inputText value="{!contactName}"></apex:inputText>
        <apex:commandButton action="{!customMethod}" value="customMethod" id="customMethod"/>
public class CustomController {
    public String contactName {get;set;}
    public void customMethod() {
        system.debug(' == contactName == ' + contactName);

Hope I am able to help,


Dushyant SonwarDushyant Sonwar
Nikhil ,

You can use the traditional way of inputting values without binding the variables.
Please check out below URL

Hope this helps!