You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 8 Members of 4087 |
| Forum: Seam Users |
22. May 2008, 19:43 CET | Link |
I’m using Seam and ICEfaces running on JBoss 4.2.2GA to complete the UI part of an application that has an exisiting HttpServlet that does SOAP processing and updates the database. I’d like to get a reference to a application-scoped Seam Component( specifically the ICEfaces’ RenderManager) so that rerendering requests can be posted to initiate rerendering of the UI screens if necessary. I’ve tried various forms of Contexts.getApplicationContext() which returns a null and Component.getInstance() reports “No application context active”. The com.icesoft.faces.async.render.RenderManager is started from the components.xml file and the re-rendering functions ok on between UI screens. Since Seam doesn’t work with a custom servlet I understand that injection of component references will not work. Is there an explicit method of getting a reference to an application scoped Seam component from a custom servlet?
Thanks
RTFM: 26.1.4.7. Context management for custom servlets
Thanks for the reference, but maybe I'm do dull to understand. The following paragraph suggests that the conversationId is supplied in a request parameter by the client.
I don't have any control over the content of the request the client sends to the HttpServlet. Or did I miss-understand the last 2 paragraphs of the section you referenced.
That sentences only relates to the conversation context which of course is not available if you do not tell seam which conversation is active.
To access the application context you only need to make sure that Seam's context filter gets wrapped around you own servlet.
Stephen Thanks, I was clearly trying to make this too hard.
I write servlet. I need get access to seam context.
component.xml:
web.xml:
<servlet> <servlet-name>My Servlet</servlet-name> <servlet-class>com.x.MyServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>My Servlet</servlet-name> <url-pattern>/x/multipleUpload</url-pattern> </servlet-mapping>User.java:
@Entity @Name("logginedUser") @Scope(ScopeType.SESSION) public class User implements Serializable { ... }MyServlet.java:
public class MyServlet extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { User user = (User) Component.getInstance("logginedUser"); // null AnyAction action = (AnyAction) Component.getInstance("anyAction"); // ok ... } }LogginedUser exist in session context after login but is not available in my servlet. If seam component is not entity then i can get it successfully. Why? How can i get logginedUser from seam context?
It's work OK. I just didn't send JSESSIONID from my flash-application by request.