webtier@glassfish.java.net

JSF 2.2, InputFile component and AJAX

From: <forums_at_java.net>
Date: Thu, 20 Sep 2012 11:09:57 -0500 (CDT)

Hi! Am I wrong or theres no option to use the build-in AJAX along with the
InputFile component (JSF 2.2)? If im not, are there plans to allow built-in
AJAX to be used with the InputFile component? It seems that theres no
configurable way to set the Content-Type value to "multipart/form-data" (at
least I didnt find it) while working with the built-in AJAX. The content-type
is beeing refused by the web server, since the file stream is not a part of a
multipart request. I do however have workarounds to allow the upload happens
asynchronously, but it involves munipulating the request wrapper at the web
server (that in my case is Tomcat 7) or even develop the client behavior.
Thanks in advance! *More about the situation I am facing* Just to make it
clear, I am using the InputFile element (which is part of JSF 2.2) with AJAX
tag as well. The following exception is thrown by the server when the AJAX
request is sent to the server, on the change event:
javax.servlet.ServletException:
org.apache.tomcat.util.http.fileupload.FileUploadBase$InvalidContentTypeException:
the request doesn't contain a multipart/form-data or multipart/mixed stream,
content type header is application/x-www-form-urlencoded;charset=UTF-8 In the
jsf.js program theres no way to configure the content-type header value for
the upload purpose. if (req.method === "POST") { if (typeof
req.xmlReq.setRequestHeader !== "undefined") {
req.xmlReq.setRequestHeader("Faces-Request", "partial/ajax");
req.xmlReq.setRequestHeader("Content-type",
"application/x-www-form-urlencoded;charset=UTF-8") } content =
req.queryString }

--
[Message sent by forum member 'Bonanza']
View Post: http://forums.java.net/node/890419