You need to sign in to do that
Don't have an account?
Visualforce action sees old value when immediate=true
I have a Visualforce page with a button, which must not perform any validations (like required value missing). These validations should only be performed later, when the user clicks another button (a save button). I use immediate="true" for that.
<apex:page controller="TestController">
<apex:form >
<apex:inputField value="{!a.Description}"/>
<apex:commandButton immediate="true" action="{!go}" value="Go"/>
{!b}
</apex:form>
</apex:page>
public with sharing class TestController {
public Account a {get;set;}
public String b {get;set;}
public Testcontroller() {
a = new Account(Description = 'x');
}
public PageReference go() {
b = a.Description;
return null;
}
}
Steps: Change the input from "x" to "y", then press Go.
Expected: "y" is printed after the Go button.
Actual: "x" is printed after the Go button.
If I remove the immediate attribute, it works. What happens here, and how can I fix it to print "y" in this case, without having the Go button perform validations?
Hi,
Try writing get set as follows:
private SomeValue;
public Account getValue() {
return SomeValue;
}
public void setValue(Account value) {
SomeValue = value;
}
Though it is similar to what you did , just give it a try.
This didn't change anything. Here is what I tried:
public with sharing class TestController {
private Account aa;
public Account getA() {
return aa;
}
public void setA(Account a) {
aa = a;
}
public String b {get;set;}
public Testcontroller() {
aa = new Account(Description = 'x');
}
public PageReference go() {
b = aa.Description;
return null;
}
}
<apex:page controller="TestController">
<apex:form >
<apex:inputField value="{!a.Description}"/>
<apex:commandButton immediate="true" action="{!go}" value="Go"/>
{!b}
</apex:form>
</apex:page>