5

Using the currrent version of Java EE, how do you create addressable web pages using Java Server Faces (JSF). That is, creating JSF pages that have a clean URL, so the page for the person entity with ID 1234 might be http://www.example.com/person/1234? It's clear enough to me how to service a clean URL using the Java API for RESTful web services (JAX-RS), but not how to do so for a JSF page, or how to combine the two.

A previous question I found suggests that doing so is not actually possible. Is that really so?

Community
  • 1
  • 1
Raedwald
  • 46,613
  • 43
  • 151
  • 237

1 Answers1

7

Use a URL rewriting solution like PrettyFaces. It uses basically a simple Filter under the covers which forwards the request from pretty to ugly URL and redirects the request from ugly to pretty URL based on some XML mapping file.

Related questions:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 3
    Wow, so it is not possible do so easilly, you have to use a third party tool to do it. That sucks. – Raedwald May 05 '11 at 14:05
  • 1
    I'm not sure why that sucks. Just drop in classpath and provide a config file. That's all. But if you insist, you can also homegrow it yourself :) At least, this is not the immediate responsibility of JSF as being "just" a component based MVC framework, so nothing "out the box" is been offered. As a completely different alternative, checkout Spring MVC. It supports RESTful URLs out the box. You only have to live with a bit more parameter handling and presentation boilerplate code as it is a request based MVC framework, not a component based one. – BalusC May 05 '11 at 14:06
  • 1
    "I'm not sure why that sucks": because JSF provides means of mapping values to URL components, but not as a clean URL, and the work-around is to translate rather than have JSF provide the functionality itself. – Raedwald May 05 '11 at 16:18