Now once user clicks submit you can pick the selcted value from the variable "PicklistSelectedVal " direct or by using the property getMyPicklistvalue()
Here is some simplified code that should work. It it does not the issue may be with your items collection and the values. You also say "If I assign the variable PicklistSelectedVal a value at the start", make sure you are doing this in the contructor.
Controller: public String picklistValue {get; set;}
Is this VF page is using any class(controller) if yes then which type of controller - Custom or Standard or Extenssion
Please let us know this so that we can help you.
Hello,
yes i'm using a controller and a extension.
Note the pickist has custom values; they are not retrieved from any object
Got it
So you are using a Controller extenssion but you are not binding this picklist with any of the field of that object.
So make a property in controller class as
class myclass
{
//Your existing code
String PicklistSelectedVal = '';
public String getMyPicklistvalue()
{
return PicklistSelectedVal;
}
public void setMyPicklistvalue(String val)
{
PicklistSelectedVal = val;
}
}
IN VF page
<apex:page .....................>
<your tags and code >............
<apex:selectList value="{!MyPicklistvalue}" >
<apex:selectOptions value="{!items}"/>
</apex:selectList><p/>
</apex:page>
Now once user clicks submit you can pick the selcted value from the variable "PicklistSelectedVal " direct or by using the property getMyPicklistvalue()
Hope this will help you....
thanks for your help
I have done this before; it is not returning any value
If I assign the variable PicklistSelectedVal a value at the start; this value is being return instead of the selected value.
You have an idea why the selected value is not being return??
Are you using a multi-select picklist?
-- Matt
Hi matt,
No its a single-select picklist
Here is some simplified code that should work. It it does not the issue may be with your items collection and the values. You also say "If I assign the variable PicklistSelectedVal a value at the start", make sure you are doing this in the contructor.
Controller:
public String picklistValue {get; set;}
Page:
<apex:selectList value="{!picklistValue}" >
<apex:selectOptions value="{!items}"/>
</apex:selectList>
Here is some expanded code that may help also: http://blog.jeffdouglas.com/2008/11/25/dependent-multilevel-selectlists/
Jeff Douglas
Informa Plc
http://blog.jeffdouglas.com