Reply To: What happened to PrettyFaces?

Splash Forums PrettyFaces Users What happened to PrettyFaces? Reply To: What happened to PrettyFaces?


I see two options if you want to navigate from non-JSF code:

1. Use constant and AddressBuilder

Use a constant for the path:

@Join(path = RecoveryBean.PATH, to="/faces/passrecovery.xhtml")
public class RecoveryBean {

  public final String PATH = "/passrecovery/{lang}/{token}/";


And then navigate like this:

String url = AddressBuilder.begin()
    .set("lang", "en")
    .set("token", "29b4033ca6f93ae78495108b629f3ec3fda055a0")


I like this one because the pattern for the path is the same for the annotation and for AddressBuilder, so using a constant makes things really easy.

2. Use Navigate and encode URL

You can also use Navigate to create a standard JSF URL and than use HttpServletResponse.encodeURL() to create the pretty URL.

String uglyUrl =
    .with("lang", "en")
    .with("token", "29b4033ca6f93ae78495108b629f3ec3fda055a0")

 * after that 'uglyUrl' will be:
 *    /faces/passrecovery.xhtml?lang=en&token=29b4033ca6f93ae78495108b629f3ec3fda055a0

String prettyUrl = response.encodeURL(uglyUrl);

 * after that 'prettyUrl' will be:
 *    /passrecovery/en/29b4033ca6f93ae78495108b629f3ec3fda055a0/


Please note .withoutRedirect() which is important to add so that Navigate creates a standard JSF URL.