jsr344-experts@javaserverfaces-spec-public.java.net

[jsr344-experts] [802-HiddenInlineFrameUpload] How to identify as "ajax" on server?

From: Edward Burns <edward.burns_at_oracle.com>
Date: Tue, 6 Nov 2012 09:24:40 -0800

>>>>> On Mon, 5 Nov 2012 10:37:02 +0100, Werner Punz <werner.punz_at_gmail.com> said:

WP> Hi Ed here is a small comment on the jsdocs in conjunction with the file
WP> uploads:

WP> Normal Ajax Part:
WP> Set the request header with the name: Faces-Request and the value:
WP> partial/ajax.

WP> That is not possible in case of the iframe request because we cannot
WP> set request headers. with iframe requests, we need another marker
WP> here for the server to identify that this is an ajax request coming
WP> in.

WP> Normally the parameter javax.faces.partial.ajax true Should be
WP> enough to identify that the request is an ajax request in that
WP> case. But the sentence "*but the request must be sent with all the
WP> parameters that a JSF XMLHttpRequest would have been sent with*"
WP> cannot hold up entirely due to the limitations of the iframe method
WP> regarding header parameters.

We already require javax.faces.partial.ajax true is sent. The reason we
use the header approach in the first place can be seen from this mail
from Jim Driscoll from 2008:

>>>>> On Tue, 16 Dec 2008 17:44:54 -0500, Jim Driscoll said:

JD> Changed the PartialViewContext to use Headers, rather than parameters,
JD> since isAjax is getting called before the view is initialized. That
JD> means that we can't access Params, since that prevents setting the
JD> character encoding on the request when the view is initialized.

I would think this restriction would also be present when sending an
"ajax" request with the hidden inline frame. Is there some other way
the server can detect the inline frame case so that it can treat it as
"ajax"?

WP> Just my 2c, regarding the fileupload jsdocs. Sorry for being
WP> nitpicky here, but this was one major issue I faced when I did my
WP> implementation of the mechanism.

You are not being nitpicky, that's the essence of what we do here.

Ed

-- 
| edward.burns_at_oracle.com | office: +1 407 458 0017
| homepage:               | http://ridingthecrest.com/