function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Syed Aswan 5Syed Aswan 5 

Selected value from SelectList is returning null

<apex:outputPanel layout="block" styleClass="requiredBlock"/>
    <apex:selectList value="{!VMW_Product}" size="1" required="true" tabindex="70">
    <apex:actionSupport event="onchange" reRender="SubStatusRerender"/>
        <apex:selectOptions value="{!VMW_Product_values}" >
        </apex:selectOptions>
    </apex:selectList>
</apex:outputPanel>

---Apex class----
Public String VMW_Product{get;set;}
system.debug('VMW_Product: '+VMW_Product);// Here it has the value 'null'
Best Answer chosen by Syed Aswan 5
Nagendra ChinchinadaNagendra Chinchinada
Try this,
 
<apex:outputPanel layout="block" styleClass="requiredBlock"/>
<apex:actionRegion >
    <apex:selectList value="{!VMW_Product}" size="1" required="true" tabindex="70">
	<apex:selectOptions value="{!VMW_Product_values}" /> 
	<apex:actionSupport event="onchange" reRender="SubStatusRerender"/> 	   
    </apex:selectList>
	</apex:actionRegion>
</apex:outputPanel>

 

All Answers

Nagendra ChinchinadaNagendra Chinchinada
Try this,
 
<apex:outputPanel layout="block" styleClass="requiredBlock"/>
<apex:actionRegion >
    <apex:selectList value="{!VMW_Product}" size="1" required="true" tabindex="70">
	<apex:selectOptions value="{!VMW_Product_values}" /> 
	<apex:actionSupport event="onchange" reRender="SubStatusRerender"/> 	   
    </apex:selectList>
	</apex:actionRegion>
</apex:outputPanel>

 
This was selected as the best answer
Syed Aswan 5Syed Aswan 5

Ch Nagendra Prasad
Thanks for the reply.

I tried but it is not working, I'm still getting the null value.

Syed Aswan 5Syed Aswan 5
Ch Nagendra Prasad
Just to clarify the things, I'm not clicking on any button or calling any function after selecting a value fron SelectList.
ShivaKrishna(Freelancer)ShivaKrishna(Freelancer)
Hi Syed,

where VMW_Product is setting with values ? I could not see that in the code u pasted. set the value for that variable either in constructor of the controller or any method (you need to keep that in <apex:page action="{!methodName}")

I believe it is giving issue as it is being set with any value at the time of page load.

let me know, if it helps you or need any help :)
shiva.sfdc.backup@gmail.com
Nagendra ChinchinadaNagendra Chinchinada
Your system.debug  will execute at the initial start of transaction and all the variables are null at that time. Once you select an option, then selected option will go to VMW_Product,  you have to call some function or you have to perform some action to execute some logic in the controller and print this value here, you will get selected value in debug.
Nagendra ChinchinadaNagendra Chinchinada
Try this,

VF page,
<apex:outputPanel layout="block" styleClass="requiredBlock"/>
<apex:actionRegion >
    <apex:selectList value="{!VMW_Product}" size="1" required="true" tabindex="70">
	<apex:selectOptions value="{!VMW_Product_values}" /> 
	<apex:actionSupport event="onchange" action="{!Printvalue}" reRender="SubStatusRerender"/> 	   
    </apex:selectList>
	</apex:actionRegion>
</apex:outputPanel>

Controller,
 
Public String VMW_Product{get;set;}
system.debug('VMW_Product before select : '+VMW_Product);// Here it has the value 'null'

Public Printvalue(){
system.debug('VMW_Product after select  : '+VMW_Product);
}

 
Nagendra ChinchinadaNagendra Chinchinada
Small correction in controller,
 
Public String VMW_Product{get;set;}
system.debug('VMW_Product before select : '+VMW_Product);// Here it has the value 'null'

Public void Printvalue(){
system.debug('VMW_Product after select  : '+VMW_Product);//It will have value
}