You need to sign in to do that
Don't have an account?
siva kumar 176
How to get field values from vf page to apex class controller
I have a checkbox in my vf page which is using custom controller. I need to get check box value true in apex class controller when it is checked, so that I can perform my logic based on that checkbox value. How to do that?
Mark this as solution, if it helped you.
Thanks
<!---------Page---------->
<apex:inputCheckbox value="{!CheckBoxValue}" id="checkBox">
<apex:actionSupport event="onclick" action="{!getSelected}"/>
<apex:inputCheckbox/>
<!---------Controller---------->
public class CheckBoxController {
public String CheckBoxValue{get;set;}
public PageReference getSelected(){
if(CheckBoxValue==true) {
//do your fuctionality
} else{
}
return Null
}
}
Check below sample code:
Visualforce Page =>
<apex:page controller="passparamFromVFtoController">
<!-- Pass parameters from visualforce page to controller -->
<apex:form >
<apex:pageblock >
Input your query <apex:inputText value="{!myInputQueryString}"/>
<apex:commandButton value="Submit" reRender="DisplayInputQueryID" action="{!myInputQuery}"/>
</apex:pageblock>
<apex:pageblock >
<b>Output : </b><apex:outputText value="{!myoutputString}" id="DisplayInputQueryID"/>
</apex:pageblock>
</apex:form>
</apex:page>
Apex Controller =>
Public with sharing class passparamFromVFtoController {
Public string myInputQueryString{get;set;}
Public string myoutputString{get;set;}
Public void myInputQuery(){
myoutputString = myInputQueryString ;
}
}
Please mark this as bext answer if it works for you.
Thanks,
Nitish