This will not help you create a link on the client, but be aware of outputLink .
There is a navigation rule redirection element that can help with some upgrade issues.
<navigation-rule>
<display-name>navBack</display-name>
<from-view-id>/navBack.jsp</from-view-id>
<navigation-case>
<from-outcome>navTo</from-outcome>
<to-view-id>/navTo.jsp</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
If all else fails, you can make the redirect URL yourself, as in this step:
public String doAction() {
System.out.println("Did some non-idempotent operation");
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext extContext = context.getExternalContext();
Application app = context.getApplication();
ViewHandler viewHandler = app.getViewHandler();
String url = viewHandler.getActionURL(context, "/navTo.jsp");
url = url + (url.indexOf('?') < 0 ? '?' : '+') + "foo=bar";
url = extContext.encodeResourceURL(url);
try {
extContext.redirect(url);
} catch (IOException e) {
throw new FacesException(e);
}
return null;
}
Cautions: I canβt remember if the URL is encoded correctly.
Different third-party libraries add different elements. I'm not sure if something was done in this area in JSF 2.0, but it might be worth a look.