You need to sign in to do that
Don't have an account?
zettahertz
inputtext null when commandbutton immediate=true
Hello everyone,
I'm facing an issue with inputtext. I don't get why the immediate=true make the inputtext return null all the time. It works fine when immediate=false. Here's a very simple plage that demonstrates it:
VF Page:
<apex:page controller="TestControllerExt"> <apex:form > Text Entered: <apex:inputText value="{!input}" /> <apex:commandButton action="{!doSomething}" rerender="panelToRerender" value="Rerender" immediate="true"/> <!-- when set to true, it returns null --> </apex:form> <apex:outputPanel id="panelToRerender"> {!output } </apex:outputPanel> </apex:page>
Controller:
public with sharing class TestControllerExt { public String input{get; set;} public String output { get; set; } public void doSomething (){ output = 'Entered value: ' + input; } }
Output:
When immediate=false:
Entered value: test
When immediate=true:
Entered value: null
I don't quite get what's going on. Is this a bug? Or that's just how immediate=true works? All i see in the document is that it bypasses validation rules, which is what I want.
This is documented behaviour. If the immediate attribute is set to true, then any input from the user is discarded.
Its not documented particularly well for the components, but in the order of execution section of the developer's guide:
--- snip ---
During a postback request, the view state is decoded and used as the basis for updating the values on the page.
Note: A component with the immediate attribute set to true bypasses this phase of the request. In other words,
the action executes, but no validation is performed on the inputs and no data changes on the page.
--- snip ---