0
votes

I have defined a form as multipart/form-data enctype. When I press a command button the request is not send with 'multipart/form-data' content-type.

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

     <input type="file" ></input>

     <p:commandButton id="save" icon="saveBt" value="#{msgs.saveBt}" ... />

</h:form>

In the developer tools console I can see the Content-Type as application/x-www-form-urlencoded; charset=UTF-8.

I'm working with JSF 2.1 and Primefaces 5.1.

Thanks

1
Are you allowed to upgrade JSF? "I'm not using <p:fileUpload> because it doesn't work with ajax and mode attribute set to "simple"". This is in fact required - mode="simple" always requires ajax="false" (It is a specified behaviour). - Tiny
I suppose you are suggesting me to upgrade to 2.2 because of h:inputFile. I'm working with JBoss 7.1 (shipped with JSF 2.1) and I'm not sure if it would be possible to upgrade to JSF 2.2 - Eduardo
I did not use JBoss either. Therefore, I am not sure about it, if it is compatible with JSF 2.2 (This is after all dependent upon Servlet version. JSF 2.2 requires at least Servlet 3.0 mainly because of <h:inputFile>). You could upgrade to JSF 2.2, if that version of JBoss (7.1) supports Servlet 3.0. - Tiny
Thanks for your idea. Probably it is possible to upgrade JBoss 7.1 to JSF 2,2, but I'm not sure if the client I'm developing for would permit to upgrade it. - Eduardo

1 Answers

0
votes

You are using JSF and Primefaces, so use <p:fileUpload> instead of <input type="file">. Take a look at official demo for an example.