Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are jftfdi jffi doing to my query string?

Tags:

jsf

jsf-2

jsf-2.2

We are using JavaServer Faces 2.2 (Mojarra 2.2.1) in our project. I noticed something odd. On a page called reporting.xhtml where I use f:metadata with the new f:viewAction my browser, Safari in this case, shows the following query string:

reporting.jsf?jftfdi=&jffi=reporting%3Ffaces-redirect%3Dtrue

What wizardry is this? What are the parameters jftfdi and jiffi doing? What is their purpose?

like image 599
raupach Avatar asked Jul 11 '13 13:07

raupach


1 Answers

It's part of the new JSF 2.2 feature as described by spec issue 949. Basically, it enables JSF to identify the client window. It's basically the same as cid in CDI's @ConversationScoped and windowId in CODI's @ViewScoped/@ViewAccessScoped. This client window ID is in turn used by among others the new JSF 2.2 @FlowScoped scope as described by spec issue 730.

The "What's new in JSF 2.2?" article of my fellow Arjan Tijms explains the need pretty clearly:

LifeCycle

Identify client windows via a Window Id

Arguably one of the biggest problems that has been plaguing web application development since its inception is the inability to distinguish requests originating from different windows of a single browser. Not only has an actual solution been long overdue, it has taken a long time to realize this even was a problem.

The root of the problem, as always, is that the HTTP protocol is inherently stateless while applications in general are not. There is the concept of a cookie though, which is overwhelmingly the mechanism used to distinguish requests from different users and to implement things like a session scope where on its turn the bulk of login mechanisms are based on.

While a cookie does work for this, it’s global per browser and domain. If a user opens multiple tabs or windows for the same domain then requests from those will all send the same cookie to the server. Logging in as a different user in a different window for the same website is thus not normally possible, and having workflows (involving post-backs, navigation) in different windows can also be troublesome because of this.

In JSF there are various solutions that are somehow related to this. The view scope effectively implements a session per window as long as the user stays on the same page and does only post-backs. The Flash is used for transferring data between different pages (presumably within the same window) when navigation is done via Redirect/GET. There’s a wide variety of scopes implemented by third parties that do something similar.

All of these have some implicit notion or assumption of the concept of a ‘client window’, but there is no explicit API for this.

JSF 2.2 will introduce support for two different aspects of this:

  • Identification of an individual window: the Client Window Id
  • API and life-cyle awareness of the window concept

Apparently you've configured your application as such.

See also:

  • What's new in JSF 2.2? - Lifecycle - Identify client windows via window Id
  • What's new in JSF 2.2? - Navigation - Faces Flow
like image 59
BalusC Avatar answered Sep 27 '22 18:09

BalusC