I'm working on a project where we needed to integrate JSF and GWT. To be more specific, we needed to have access to JSF beans in the GWT services. Because I missed the methods getThreadLocalRequest() and getThreadLocalResponse() in RemoteServiceServlet, I had to search quite a bit before i found an answer to this problem. So to save others some time i post the class i came up with. Most of the code is taken from an article at ocpsoft.com which also points out how important it is to release the context when you're done with it. The big difference are the lines, UIViewRoot view = facesContext.getApplication().getViewHandler().createView(facesContext, "gwtViewID"); facesContext.setViewRoot(view); , which sets the view root. If no view root is set you can't use, for instance MessageBundles. The getBean methods are only convenience methods for retrieving beans by name. /** * A substitute for RemoteServiceServlet that has access to the FacesContext. */ @Sup
Comments