Pass request parameters through FacesContext
12,266
In step 2, if there is a redirect the initial request scope is lost as the redirect would result in another request.
Author by
Vladimir
Updated on June 04, 2022Comments
-
Vladimir almost 2 years
I moved from JSF 1.2 to JSF 2.0 and it seems I missed something during the switch. I have following scenario:
- There is a button on one page with actionListener set to one managed bean's method which adds an object to request by calling
FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("foo", fooObject);
- Navigation is properly handled to other page where other managed bean is initialized.
- The constructor of other managed bean tries to retrieve passed object from request by calling
FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("foo");
and to initialize itself with received values.
Both managed beans are request scoped. I notice that constructor can't retrieve proper value from request because request map doesn't contain "foo" key.
What am I doing wrong? Is there a better way to do this?
Thanks in advance.
- There is a button on one page with actionListener set to one managed bean's method which adds an object to request by calling
-
Vladimir over 13 yearsThank you for your reply. Yes, you're absolutely right. There was <redirect> element in faces-config.xml and when I removed it parameters were correctly passed.
-
Mr. Port St Joe about 9 yearsThank you for the knowledge. Much appreciated.