You need to sign in to do that
Don't have an account?
Pritam Patil 19
Picklist Value returned in Apex Class is "null"
Hello,
I am trying to pass selected picklist value to apex class dynamically using actionsupport, but when I check using debug logs I am getting the value as null. I need this value as I have to get data from query to populate another custom picklist.
Below is my code:
VISUALFORCE PAGE:
//FIRST PICKLIST
<apex:selectList size="1" id="ApplicationDrop" value="{!ApplicationVar}" >
<apex:actionSupport event="onchange" reRender="FBiasR" status="rend"/>
<apex:selectOptions value="{!ApplicationOptions}"></apex:selectOptions>
</apex:selectList>
//SECOND PICKLIST
<apex:selectList size="1" id="FBiasR" value="{!FBiasRVar}">
<apex:selectOptions value="{!FBRItems}"></apex:selectOptions>
</apex:selectList>
APEX CLASS:
public List<SelectOption> getFBRItems() {
system.debug('APPLICATION ------------->'+ApplicationVar);
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('None','None'));
for(AggregateResult ar : [Select Recommendation__c from Fleet_Recommendation__c where Axle__c = 'Front' AND Tyre_Class__c = 'Bias' AND Application__c =:ApplicationVar GROUP BY Recommendation__c])
{
options.add(new SelectOption(String.valueOf(ar.get('Recommendation__c')),String.valueOf(ar.get('Recommendation__c'))));
}
return options;
}
I have done this same functionality on another VF page there it is working correctly with the same code. Need Help!
I am trying to pass selected picklist value to apex class dynamically using actionsupport, but when I check using debug logs I am getting the value as null. I need this value as I have to get data from query to populate another custom picklist.
Below is my code:
VISUALFORCE PAGE:
//FIRST PICKLIST
<apex:selectList size="1" id="ApplicationDrop" value="{!ApplicationVar}" >
<apex:actionSupport event="onchange" reRender="FBiasR" status="rend"/>
<apex:selectOptions value="{!ApplicationOptions}"></apex:selectOptions>
</apex:selectList>
//SECOND PICKLIST
<apex:selectList size="1" id="FBiasR" value="{!FBiasRVar}">
<apex:selectOptions value="{!FBRItems}"></apex:selectOptions>
</apex:selectList>
APEX CLASS:
public List<SelectOption> getFBRItems() {
system.debug('APPLICATION ------------->'+ApplicationVar);
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('None','None'));
for(AggregateResult ar : [Select Recommendation__c from Fleet_Recommendation__c where Axle__c = 'Front' AND Tyre_Class__c = 'Bias' AND Application__c =:ApplicationVar GROUP BY Recommendation__c])
{
options.add(new SelectOption(String.valueOf(ar.get('Recommendation__c')),String.valueOf(ar.get('Recommendation__c'))));
}
return options;
}
I have done this same functionality on another VF page there it is working correctly with the same code. Need Help!
I got the issue. Actually there were some required fields and their required validation was interfering with the reRendering of the picklists.
Tip for all who are doing this : Add <apex:pagemessages id='msgs'/> to your visualforce page and reRender 'msg' in actionSupport. So that you are notified about the errors occuring and take actions required.
All Answers
field level security is 'Visible', the problem is i am not getting ApplicationVar in apex class hence the query is not working.
I got the issue. Actually there were some required fields and their required validation was interfering with the reRendering of the picklists.
Tip for all who are doing this : Add <apex:pagemessages id='msgs'/> to your visualforce page and reRender 'msg' in actionSupport. So that you are notified about the errors occuring and take actions required.