Values returned from JSF 2 method isPostback on EAP 6.
Environment
- Red Hat JBoss Portal
- 6.1.0
- Red Hat JBoss Enterprise Application Platform
- 6.x
Issue
- When using forward in order to go to other page, isPostBack() is always true.
- Where as while using redirect isPostBack() is false.
Is this a correct functioning?
Resolution
-
Firstly for a new request the isPostBack() value is false.
-
This is a default JSF behaviour where navigation always happens through "Forward" under the hood where same/new request is forwarded to the next page and form is submitted hence isPostBack() is true.
-
When using
, the link posts to “a.faces”, but now,instead of forwarding to “b.faces”, JSF returns a 302 (redirect) response. This triggers the browser to load the “b.faces” using a new request and since its a new request its always isPostback =false .
Attached to this article is a JSF example. One can change the faces-redirect value (true/false) in the main.xhtml to see the behaviour.
The application needs to be accessed using url http://localhost:8080/jsfApp/pages/main.faces
Attachments
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
