2

I came to know that from JSF 2.0 the URL can be changed in the address bar. It is more helpful to bookmark the URL. Is there any way to do in the JSF 1.x versions.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Krishna
  • 7,154
  • 16
  • 68
  • 80

2 Answers2

3

No. But there are some common practices to achieve better bookmarkable URL's in JSF 1.x:

  • Do not navigate to another page after submit, always return to the same page and display any error/success messages by h:message(s).

  • If you really need to go to a different page after submit, prefer to do it by a redirect. It will cause the browser to fire a brand new GET request on the given URL.

  • Do not use h:commandLink/h:commandButton (which fire POST) for plain page-to-page navigation. Use h:outputLink or just plain HTML a elements. It's also better for SEO.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • How we can do the redirect in the JSF? Is it using the any configuration in Faces-config.xml?. Thank you for the answer. – Krishna Jan 25 '11 at 05:13
  • 2
    Either by calling `ExternalContext#redirect()` or by adding `` entry to the `` in `faces-config.xml`, if any (in JSF 2.0, you can also do this by adding `?faces-redirect=true` to the outcome value). – BalusC Jan 25 '11 at 05:16
1

If you are willing/able to extend your JSF 1.2 installation, you could also take a look at PrettyFaces (http://ocpsoft.com/prettyfaces/), which adds a lot of extra support for bookmark-able URLs.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140