0

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?

mabi
  • 5,279
  • 2
  • 43
  • 78

1 Answers1

0

I think the problem is that a RichFaces-component does the rerendering of the form: I made a small testpage where I observed the same with other RF 4 components (like a4j:commandButton). The "rerender the form"-workaround is only working if this is done by f:ajax.

Concerning your edit: I tried the snipped from BalusC too, but it was not working with RichFaces components again. So I tried a slightly different approach which is posted here. Maybe you can take a look at it.

As written there I'm not 100% sure if this is a correct solution for all cases, but at the moment this works for me.

Community
  • 1
  • 1
MrD
  • 1,255
  • 1
  • 10
  • 24