You need to sign in to do that
Don't have an account?
prabhavathi sharma
how to call the apex method in visualforce page
how to call the apex method in visualforce page. where I did mistake tell me. I am getting this Error: Unknown property 'Example.name
I wrote this code
Apex code
public class Example
{
pubic string name;
public string getName()
{
return name;
}
public void setName(string name)
{
this.name=name;
}
public pagereference show()
{
name='This is my name'+name;
return null;
}
}
Visualforce code
<apex:page controller="Example">
<apex:form>
<apex:outputlabel>Enter Name</apex:outputlabel>
<apex:inputtext value="{!name}"/>
<apex:commandButton value="click" rerender="one" action="{!show}"/>
<apex:outputLabel id="one">{!name}</apex:outputLabel>
</apex:form>
</apex:page>
I wrote this code
Apex code
public class Example
{
pubic string name;
public string getName()
{
return name;
}
public void setName(string name)
{
this.name=name;
}
public pagereference show()
{
name='This is my name'+name;
return null;
}
}
Visualforce code
<apex:page controller="Example">
<apex:form>
<apex:outputlabel>Enter Name</apex:outputlabel>
<apex:inputtext value="{!name}"/>
<apex:commandButton value="click" rerender="one" action="{!show}"/>
<apex:outputLabel id="one">{!name}</apex:outputLabel>
</apex:form>
</apex:page>
use below code , i think name is a reserved keyword for use in public class varibale. thanks
mark it best answer if my answer helps you so it make proper solution for others
Name is not Keyword . You just need to add getter and setter for Name Field.
You can try below code
Page like below
I tested the same code in my developer org which is working fine
Please check below post for Getter Setter
1) https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_methods.htm
2) http://www.forcetree.com/2009/07/getter-and-setter-methods-what-are-they.html
3) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_properties.htm
Let us know if you need more help.