3

I'm having problems with using multi-part form. I have started my project on TomEE 1.6 which came with the following JSF implementation:

myfaces-api-2.1.13
myfaces-impl-2.1.13

I read it's OK to upgrade JSF on TomEE so I replaced those two with:

myfaces-api-2.2.0
myfaces-impl-2.2.0

Unfortunately, multi-part form isn't working. When I use a simple form, the Save button goes into the bean target method properly. As soon as I add enctype="multipart/form-data" to the form tag, the Save button no longer works. A request goes to the server but the target method isn't called. This, basically, results in a form refresh with all data lost.

My faces-config

<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
    http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.2">

My code

<h:form id="form" enctype="multipart/form-data">

<h:commandButton value="#{messages['common.buttonLabel.save']}" action="#{fileEditBean.save}" rendered="#{fileEditBean.hasSaveAction()}" />
Leo
  • 6,480
  • 4
  • 37
  • 52
jacekn
  • 1,521
  • 5
  • 29
  • 50
  • where did you read it was ok to replace myfaces libs? – Leo Feb 22 '14 at 01:11
  • I suppose your file upload code works with 2.1.13 right? – Leo Feb 22 '14 at 01:15
  • could reproduce your problem here. In tomee mailing list, it has been said at Jan 15th (thread "When will MyFaces 2.2.x be bundled with TomEE 1.6.x ?") that we could just switch myfaces libs to 2.2.0. I've tried here with p:fileUpload and I could reproduce your bug. It really seems related to myfaces 2.2.0. I haven't found any JIRA issue about that at myfaces site. – Leo Feb 22 '14 at 01:47
  • maybe this is related to http://stackoverflow.com/questions/20316773/primefaces-4-0-fileupload-works-with-mojarra-2-2-but-not-myfaces-2-2 – Leo Feb 22 '14 at 01:49
  • email sent to myfaces and tomee mailing lists – Leo Feb 22 '14 at 01:59
  • Hi Leo! I've been looking for a solution on file upload for a whole day and between Tomahawk and other ideas, there were mentions of upgrading jsf implementation to latest. I won't say that all that referred to myfaces but in case of TomEE, I understand quoted files were the ones to use. – jacekn Feb 22 '14 at 04:30
  • As for jsf 2.1, I'd need to use a non-jsf solution to support uploading files, which to me is a bit odd given the age of jsf technology. So I opted to upgrade the implementation. – jacekn Feb 22 '14 at 04:32
  • I'll stick with vanilla tomee with MF 2.1.13 while it still works for me :-) – Leo Feb 22 '14 at 05:01
  • @lu4242 (Leonardo Uribe, MyFaces lead/committer) responded to Leo's mail on myfaces user list, and Leonardo Uribe stated that the simple example, [JSF 2.2: File upload with h:inputFile](http://jsflive.wordpress.com/2013/04/23/jsf22-file-upload/), works while using MyFaces 2.2. He also said that JSF 2.2 fileUpload relies on servlet 3.0. did you specify servlet 3.0 in your web.xml? – Howard Mar 04 '14 at 12:21
  • Yes, I am on servlet 3.0. I couldn't get upload to work, so I went with Tomahawk. Then I noticed some strange problems in my pagination mechanism so I reverted back to MyFaces that comes with TomeEE and things are OK. Both Tomahawk upload and my pagination works on MyFaces 2.1. – jacekn Mar 05 '14 at 23:53

0 Answers0