I am new to JSF 2.0. I am stuck in the following problem. I have a page from which a bean-driven action method. That I am doing some custom processing and this goes to another xhtml page. Now the problem is that before moving on to the next xhtml page, I also need to pass some parameters along with it. I used the following approaches
1- Put this variable in requestMap and try to access this page this way
<h:outputText value="#{param['userid']}"/>
he does not work. Then someone told me that there is no standard way to pass JSF 2.0 request parameters along with the URL, so try passing it as a servlet request. I will die the code as follows
ServletRequest request = (ServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); ServletResponse response = (ServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse(); //("user",user); //ServletRequest request = (ServletRequest)context.getRequest(); request.setAttribute("userid", "prithvi"); System.out.println("Came here"); RequestDispatcher rd = request.getRequestDispatcher("testf.xhtml"); try { rd.forward(request, response); } catch (ServletException ex) { Logger.getLogger(TestFlashScope.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(TestFlashScope.class.getName()).log(Level.SEVERE, null, ex); }
I tried to access in the same way, but no luck. value is not displayed. Can someone help me how to achieve this solution.
BR, Prithvi
user599962
source share