You need to sign in to do that
Don't have an account?
SathishKumar
Pass Value From visualforce page to apex controller
Hi All,
I am completely new to Apex and visualforce progamming.
I was trying to develop a visualforce page, which accepts values and i am trying to display the accepted values in debug screen.
I ve written the following vf page:
<apex:page controller="setExample">
<apex:form>
<apex:outputLabel>Enter u r name</apex:outputLabel>
<apex:inputText value= "{!name}" />
<apex:commandButton value="Click" rerender="one"/>
<apex:outputLabel id="one">Name is {!name} </apex:outputLabel>
</apex:form>
</apex:page>
and below controller
global class setExample {
public String name;
public Integer age;
public void setName(String name){
this.name = name;
System.debug('Name ='+name);
}
public void setAge(Integer age){
this.age = age;
System.debug('Age is '+age);
}
}
i am getting following error
Unknown property 'setExample.name'
Please guide me, where am i going wrong.
Thanks in advance
I am completely new to Apex and visualforce progamming.
I was trying to develop a visualforce page, which accepts values and i am trying to display the accepted values in debug screen.
I ve written the following vf page:
<apex:page controller="setExample">
<apex:form>
<apex:outputLabel>Enter u r name</apex:outputLabel>
<apex:inputText value= "{!name}" />
<apex:commandButton value="Click" rerender="one"/>
<apex:outputLabel id="one">Name is {!name} </apex:outputLabel>
</apex:form>
</apex:page>
and below controller
global class setExample {
public String name;
public Integer age;
public void setName(String name){
this.name = name;
System.debug('Name ='+name);
}
public void setAge(Integer age){
this.age = age;
System.debug('Age is '+age);
}
}
i am getting following error
Unknown property 'setExample.name'
Please guide me, where am i going wrong.
Thanks in advance
You have to declare name like this in controller to access it in VF page.
Public string name{get;set}
Try this class
Let me know if you have any issues.
Mark it as best answer if it works.
Thanks.