Question

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 submited.

Example: String.valueOf(textArea.getValue()).equals("")) when it is first sumited the code String.valueOf(textAreaOcorrencia.getValue()) is null, but since the textArea was empty it was suposed to be an empty string. When it is submited 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 cicle , but i don't know how to update these values?

Thanks in advance...

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top