JSF 2.2 - fileupload does not work with Ajax. Form appears to have incorrect enctype (only via AJAX) -


trying implement jsf 2.2 example have following code:

<h:form prependid="false" enctype="multipart/form-data">      <!-- it's ajax file upload component -->     <h:inputfile id="fileupload" value="#{somebean.file}" >         <f:ajax />     </h:inputfile>      <h:commandbutton value="upload" /> </h:form> 

according jsf 2.2 should work in case giving me following error:

the request doesn't contain multipart/form-data or multipart/mixed stream, content type header application/x-www-form-urlencoded;charset=utf-8

looking request although have set form enctype correctly, partial request submits:

content-type:application/x-www-form-urlencoded;charset=utf-8 faces-request:partial/ajax

note web.xml modified to:

<servlet>     <servlet-name>faces servlet</servlet-name>     <servlet-class>javax.faces.webapp.facesservlet</servlet-class>     <load-on-startup>1</load-on-startup>     <multipart-config>         <location>c:\dotmp</location>         <max-file-size>20848820</max-file-size>         <max-request-size>418018841</max-request-size>         <file-size-threshold>1048576</file-size-threshold>     </multipart-config> </servlet> 

i using mojarra 2.2.0-m15 tried earlier versions well. know useful info issue, assume bug?

i'm not sure what's going on haven't seen before. following construct works me when using today's mojarra 2.2.1 snapshot can download "implementation jar" link mentioned in what's new in jsf 2.2?

<h:form enctype="multipart/form-data">     <h:inputfile value="#{bean.file}" required="true">         <f:ajax listener="#{bean.handlefileupload}" render="@form" />     </h:inputfile>     <h:messages /> </h:form> 

with

private part file;  public void handlefileupload(ajaxbehaviorevent event) {     system.out.println("file size: " + file.getsize());     system.out.println("file type: " + file.getcontenttype());     system.out.println("file info: " + file.getheader("content-disposition")); }  // ... 

i recommend give newer mojarra version try. apparently there bug in older mojarra version failed create proper multipart/form-data request using <iframe> hack caused error. mxx versions beta versions anyway , should not relied upon production. error theoretically have been browser-specific, works fine me in chrome 26, firefox 20 , ie 10.

the issue i'm seeing hidden <iframe> still visible in chrome , firefox below:

enter image description here

it appears they're forgotten set frameborder attribute 0 in generated <iframe>. i've reported issue 2861 that.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -