I am using a <rich:tabpanel> with 3 tabs. In the 2nd tab I have 3 <rich:fileUpload> components. All the 3 fields are mandatory. Hence I perform validation in the backing bean on submit of the contents in the page.
If I select a file in one of the file upload components and leave other 2 empty, then I get the validation messages for the 2 empty components as expected. However the first component is also re-rendered and is not retaining the selected file, even though the file contents are still stored in the property of the backing bean.
How can I retain the selected file on re-render?
Just do not re-render the input fields itself, but only the holder(s) of the validation messages. You can do that with
<a4j:commandButton>wherein you specify the IDs of the message component(s) in thereRenderattribute (I am assuming that you’re using RichFaces 3.3, not 4.0, as it’s not by default possible to have a single file selection for file upload in the current 4.0).Note that you don’t need to validate for requireness in the action method. Just setting
required="true"on the input component(s) is sufficient.