I am currently learning JSF and was rather amazed and puzzled when I realized that whenever we use <h:form>
, the standard behavior of JSF is to always show me the URL of the previous page in the browser, as opposed to the URL of the current page.
I understand that this has to do with the way JSF always posts a form to the same page and then just renders whatever page the controller gives it back to the browser which doesn't know the page location has changed.
It seems like JSF has been around for long enough that there must be a clean, solid way to deal with this. If so, would you mind sharing?
I have found various workarounds, but sadly nothing that seems like a real solid solution.
- Simply accept that the URL is misleading.
- Append
"?faces-redirect=true"
to the return value of every bean's action and then- figure out how to replace
@RequestScoped
with something else (Flash Scopes, CDI conversation, @SessionScoped, ...). - accept to have two HTTP round trips for every user action.
- figure out how to replace
- Use some method (e.g. 3rd party library or custom code) to hide the page name in the URL, always using the same generic URL for every page.
If "?faces-redirect=true"
is as good as it gets, is there a way do configure an entire application to treat all requests this way?