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.

Share:
12,266
Vladimir
Author by

Vladimir

Updated on June 04, 2022

Comments

  • Vladimir
    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:

    1. 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);
    2. Navigation is properly handled to other page where other managed bean is initialized.
    3. 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.

  • Vladimir
    Vladimir over 13 years
    Thank 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
    Mr. Port St Joe about 9 years
    Thank you for the knowledge. Much appreciated.