JSF Nice URL

Possible solutions

 * | Using Ajax and JSF
 * Phase listeners and get requests
 * Pretty URL
 * (from 16.03.2008) Blog entry
 * Java Sun Forum
 * Post and Redirect get pattern

Implementation
I tested the solution provided by : http://tuckey.org/urlrewrite/.

It works fine. I have now (in Faces) :
 * server/faces/Home instead of server/faces/faces/HomePage.jsf
 * server/faces/Details/escidoc:6423 instead of server/faces/faces/Details.jsf?item=escidoc:6423

Now we have to decide which parameters have to be written in the URL.

For Faces I propose:
 * Details view : ID of the person
 * Home page : current page, sort criterium (criteria? for R2), sort order.
 * Search Result : home page parameters + search parameters

Installation
Download the package 3.1 from : http://tuckey.org/urlrewrite/

Extract and copy the file urlrewrite.xml in your WEB-INF.

In your dependencies in the pom.xml, copy and paste :

In web.xml insert:

Basic use
There are 2 different ways to use urlrewrite:

1. Rules There are defined as following:

Simple example:

2. Outbound-rules There are define as following: Simple example:

This 2 mechanism are two different ways to use rewriteurl. Therefore I recommend for more simplicity to use only one of this two. After a couple of try, the one which appear to me the most simple to use is the first one, the rule.

Parameters
To define parameters, urlrewrite provide the following solution:
 * In that example the url will look like: http://faces.mpdl.mpg.de:8080/faces/person/066
 * Parameters are define between the bracket with a regular expression. Then, to define it as parameter, just write the definition of this parameter element  with $1 if it is the first parameter, $2 for the second, etc.
 * You can also notice that there is the possibility to define fixed parameters values which don't appear in the url, i.e. page=1.
 * One important point is not to forget to start every rules with ^ and to close their with $. In regular expressions ^ specifies the start of the string and $ specifies the end. Thus you are sure to avoid non expected matching.

To read the parameters in your java code, proceed as following:

Remarks

 * Apache rewrite rules might interfere with urlrewrite rules. For example in Faces, in etc/apache2/vhosts.d/faces.conf were define some rewrite rules. My own rewrite rules didn't work then from Apache and I had to call jboss directly with port 8080 to make my rules working. Be careful!
 * This page is a very small summary of what is urlrewrite. I strongly recommend to read for more information : http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/3.1/index.html.