I'm having a problem submitting a two-forms template, where one of the <h:form>
s is a multipart/form-data
(ie, used to submit files via Richfaces4's rich:fileUpload
).
The basic template looks like this:
<h:form enctype="multipart/form-data">
<rich:fileUpload fileUploadListener="#{uploader.doUpload}" execute="@form" render="@form :inputForm" />
</h:form>
<h:form id="inputForm">
<h:inputText value="#{uploader.input1}" />
<h:commandButton action="#{uploader.save}" value="Save" />
</h:form>
There's also a page.xml for this template, which invokes an action:
<action execute="#{uploader.selectObjectsFromRequest}" on-postback="false" />
My problem is that selectObjectsFromRequest
keeps getting called when I click the "Save" button.
Debugging this, FacesContext.getCurrentInstance().isPostback()
returns false in this case and true enough, the form is submitted without javax.faces.ViewState
.
I'm aware that losing the ViewState is a JSF bug and we're supposed to explicitly re-render forms to restore their state. But this is what I'm already doing.
So, is this a bug in Richfaces?
Edited to add: Adding the Workaround javascript snippet posted by BalusC here restores the ViewState and makes the form submit correctly. So maybe someone can shed light on why the explicit re-render is not enough in this case?