You need to sign in to do that
Don't have an account?
ezhil_k
<apex:inputCheckbox > value is not getting passed from page to controller
Always the value of acceptTerms is showing as false even the check box is checked in the page.
Please help me out to solve this.
vf Page:
<apex:inputCheckbox value="{!acceptTerms}"/>
controller:
public class controller {
Public boolean accepTerms;
Public controller(){
accepTerms=false;
}
if(!acceptTerms)
apex.addmessage(' ' );
}
Please help me out to solve this.
vf Page:
<apex:inputCheckbox value="{!acceptTerms}"/>
controller:
public class controller {
Public boolean accepTerms;
Public controller(){
accepTerms=false;
}
if(!acceptTerms)
apex.addmessage(' ' );
}
In the constructor you are initialised the variable with false.
As we all know at first constructor will get excuted first. So value 'false' is assigned.
pls change the controller code like this.
public class controller {
Public boolean accepTerms{get;set;}
Public controller(){
}
if(!acceptTerms)
{
apex.addmessage(' ----value---False---- ' );
}
else
{
apex.addmessage(' ----value---True---- ' );
}
please select this as solution if you got your answer.
Thanks.
Praveen Murugesan
Something as
public boolean accepTerms{get; set;}
if(acceptTerms){
//do something
}
Attempt to de-reference a null object
Even after putting { get;set;} its not working out.
You should initialise the variable with get;set; property. But in outside the constructor.
So you will not get the error.
In the above code which I wrote,
public class controller {
Public boolean accepTerms{get;set;} // Here i am intializing
Public controller(){
}
if(!acceptTerms)
{
apex.addmessage(' ----value---False---- ' );
}
else
{
apex.addmessage(' ----value---True---- ' );
}
If you checked the checkbox then the output value will be ----value---True----
Thanks,
Praveeen Murugesan.
Found the issue
Change the code like this,
public class controller {
Public boolean accepTerms{get;set;} // Here i am intializing
Public controller(){
if(accepTerms == true) //we should not do like this if(!acceptTerms)
{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'----value---False----');
ApexPages.addMessage(myMsg);
}
else
{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'----value---True----');
ApexPages.addMessage(myMsg);
}
}
}
please select this as solution if you got your answer.
Thanks.
Praveen Murugesan
No Praveen, We have controllers same like wat i did : if(!acceptTerms)
This statement is working in those.
The thing is its not passing the value from page.
Or send me a mail. My mail id is ppraveenm@gmail.com