+ Start a Discussion
Binu 8Binu 8 

Input filed binding with controller not working properly

Hi Team,

I have a custom controller which name is "PaypalProccessor",
The code is,

public class PaypalProccessor{
    public  string amount {set;get;};
    public  String balance {set;get;}
    public  string FirstName{get; set; }
    
    public String doDirectPayment()
    { 
    }
}

And in my Visual force page I want to enter these 3 details in to an input field,The code is

<apex:page controller="PaypalProccessor">
    <apex:form>
        <apex:pageBlock title="Paypal Payment">
            <apex:outputLabel value="Amount" for="amt"/>
              <apex:inputField value="{!PaypalProccessor.amount}" id="amt"/>
            <apex:commandButton  value="save" action="{!doDirectPayment}"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>

But I am facing this error in VF,

Unknown Property 'PaypalProccessor.PaypalProccessor'.

I think the error is coming from the binding of input field and also tried value="{!amount}".
That time the error will be ,

"Could not resolve the entity from &lt;apex:inputField&gt; value binding '{!amount}'. 
 &lt;apex:inputField&gt; can only be used with SObjects, or objects that are Visualforce field component resolvable."
Best Answer chosen by Binu 8
KaranrajKaranraj
Binu - <apex:inputField> can be used only with the sObject fields only where the 'Amount' is not an sObject field so you are getting that binding error message. You have to use <apex:inputText> try the updated below code
 
<apex:page controller="PaypalProccessor">
    <apex:form>
        <apex:pageBlock title="Paypal Payment">
            <apex:outputLabel value="Amount" for="amt"/>
              <apex:inputText value="{!amount}" id="amt"/>
            <apex:commandButton  value="save" action="{!doDirectPayment}"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Thanks,
Karanraj (http://www.karanrajs.com)

All Answers

Shrikant BagalShrikant Bagal

Please use followong VF Code:
 

<apex:page controller="PaypalProccessor">
    <apex:form>
        <apex:pageBlock title="Paypal Payment">
            <apex:outputLabel value="Amount" for="amt"/>
              <apex:inputField value="{!amount}" id="amt"/>
            <apex:commandButton  value="save" action="{!doDirectPayment}"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>
If its helps, please mark as best answer so it will help to other who will serve same problem.
T​hanks! 
Binu 8Binu 8
I tried this also. But the error is,

"Could not resolve the entity from &lt;apex:inputField&gt; value binding '{!amount}'. 
 &lt;apex:inputField&gt; can only be used with SObjects, or objects that are Visualforce field component resolvable."
 
Shrikant BagalShrikant Bagal
Hello Binu,

Try following code:
 
<apex:page controller="PaypalProccessor">
    <apex:form>
        <apex:pageBlock title="Paypal Payment">
            <apex:outputLabel value="Amount" for="amt"/>
              <apex:inputText value="{!amount}" id="amt"/>
            <apex:commandButton  value="save" action="{!doDirectPayment}"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>


If its helps, please mark as best answer so it will help to other who will serve same problem.
T​hanks! 
 
KaranrajKaranraj
Binu - <apex:inputField> can be used only with the sObject fields only where the 'Amount' is not an sObject field so you are getting that binding error message. You have to use <apex:inputText> try the updated below code
 
<apex:page controller="PaypalProccessor">
    <apex:form>
        <apex:pageBlock title="Paypal Payment">
            <apex:outputLabel value="Amount" for="amt"/>
              <apex:inputText value="{!amount}" id="amt"/>
            <apex:commandButton  value="save" action="{!doDirectPayment}"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Thanks,
Karanraj (http://www.karanrajs.com)
This was selected as the best answer