I am new to JSF 2.0. I am stuck at the following problem. I have a page from which a managed bean action method is called. In that i do some custom processing and the it navigates to another xhtml page. Now the problem is that, before moving to next xhtml page, i need to pass some parameters along with it as well. I have used the following approaches
1- Put that variable in requestMap and tried to access in the page this way
<h:outputText value="#{param['userid']}"/>
it doesn't work. Then someone told me there is no standard way in JSF 2.0 to pass request parameters along with a URL, so try to pass it as a servlet request. I ammened 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 same way but no luck. no value is displayed. Can someone help me how to achieve this solution.
BR, Prithvi