I have a page with a radio selection with 3 options and a inputTextArea
. When I press the submit button on my page, then I need to do some validations... In order to do so, I put a validator on the radio. The problem is that when the validator is executed, I need the values of the inputTextArea
and of the radio, but they come with old values, not the ones that were defined on the page before the page was submitted.
Example: String.valueOf(textArea.getValue()).equals(""))
when it is first submitted the code String.valueOf(textAreaOcorrencia.getValue())
is null
, but since the textArea
was empty it was supposed to be 开发者_运维知识库an empty string. When it is submitted for the second time, it has the value of what it was supposed to have in the 1st submission. I know that this has something to do with the JSF life cycle, but I don't know how to update these values?
During the apply request values phase, the submitted values will be set and available as submittedValue
. During the validations phase, the submitted values will be validated and converted and set as value
. The components are validated in the top-bottom order as the components appear in the component tree.
Thus, if the component in question actually appears after the current component in the component tree, you'll need to get its value by UIInput#getSubmittedValue()
instead of UIInput#getValue()
.
To learn more about the JSF lifecycle, you may find this self-practice article useful.
精彩评论