On Sun, 2009-01-18 at 08:52 -0800, bansi wrote:
> I am using JSF 1.2, RichFaces 3.1 wondering if any of these technologies
> support Bookmarking.
> Googling i found PrettyFaces, RestFaces extend JSF to support Bookmarking
> 
> But we don't want to add new frameworks to our project and would like to get
> it done with available frameworks.
> 
> Any pointers/suggestions will be greatly appreciated 

Bookmarkable pages within a webapp are a problem with JSF.

The main issues are:

(1)
The general problem is that JSF is intended to be a framework for
building webapps with very rich/complex pages, ie pages with lots of
html input components in them. And that means that there can be lots of
data being passed back to a server on each submit. Therefore JSF takes
the approach of using POST requests almost all the time - and those of
course don't bookmark well.

Some other frameworks do much better at generating bookmarkable urls -
but may be much worse at handling complex pages. Like all things,
finding one approach that handles both simple and complex requirements
isn't easy.

(2)
JSFs default approach for navigating from one page to another is for the
first page to do a post, user logic determines what page to navigate to,
and then a "forward" occurs internally within the webserver to render
the "next" page, all within the same http request cycle. This is the
most efficient for network traffic, but leads to the well-known "browser
url shows previous page" problem because the browser shows what url it
POSTed to, not what page eventually got rendered.

You can fix (2) by using <redirect/> in JSF navigation rules, at the
cost of some performance. Unfortunately this also makes the server-side
logic harder though. The normal approach of passing data from one page
to the next page is via request-scoped variables, but that just doesn't
work if a <redirect/> is used, as the new page is rendered in a
different http request. The Tomahawk RedirectTracker stuff tries to work
around this, but it's not terribly elegant. See the myfaces wiki for
further info on the limitations of <redirect/>

Note however that using redirect still doesn't help if you want to
create links that have *parameters* in them, eg
   /showUser?id=20
JSF just assumes any params are in a form, not in a query.

If you have just a couple of pages where you want urls with parameters
in them, then you can manually add the necessary links and use tricks to
manually check for and handle the parameters. But if it's more than a
couple of pages, then using one of the libraries you listed above is
definitely a better idea.


The committee that is designing JSF are aware of the issue, but they
haven't come up with any standard solution yet.

Regards,
Simon


Reply via email to