Background
I have a VF page that use StandardController="Opportunity"
and also extensions="OpportunityControllerExt"
.
I'm showing the opp.stageName and the opp.Probability. When the StageName changes I need to update the right probability.
Approach
I've created a map<stageName,probability>
and also a actionSupport onchange
that update the probability (for visualisation) on my extension.
sample code:
page:
<apex:actionRegion >
<apex:inputField value="{!Opportunity.StageName}" id="status">
<apex:actionSupport event="onchange" action="{!updateProbability}"
rerender="blockSection" immediate="true">
</apex:actionSupport>
</apex:inputField>
</apex:actionRegion>
<apex:inputField value="{!Opportunity.Probability}" id="probability"/>
extension:
public class OpportunityControllerExt {
public static Opportunity opp {get;set;}
private map<string,decimal> probabilities = new map<string,decimal>();
public OpportunityControllerExt(ApexPages.StandardController stdController){
OpportunityControllerExt.opp = (Opportunity)stdController.getRecord();
.....
}
public PageReference updateProbability(){
//probabilities map was made before
OpportunityControllerExt.opp.Probability = probabilities.get(OpportunityControllerExt.opp.StageName);
return null;
}
The method is called fine, but...
Problem
The referenced Opp on my extension is not getting the updated value of stageName. I think that I'm doing something wrong when i'm binding the opp record.
Question
Is any way to get a changed field value from and extension and then update the value of other field?