Help

Controls

PermLinkWikiLink

Built with Seam

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.

Forum: Seam Users Forum ListTopic List
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

6 Replies:
22. May 2008, 21:20 CET | Link

RTFM: 26.1.4.7. Context management for custom servlets

22. May 2008, 22:26 CET | Link

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.

The context filter expects to find the conversation id of any conversation context in a request parameter named conversationId. You are responsible for ensuring that it gets sent in the request.

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.

23. May 2008, 12:25 CET | Link

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.

23. May 2008, 21:20 CET | Link

Stephen Thanks, I was clearly trying to make this too hard.

21. Jul 2008, 11:45 CET | Link

I write servlet. I need get access to seam context.

component.xml:


<web:context-filter url-pattern="/x/*" />

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?

01. Aug 2008, 12:25 CET | Link

It's work OK. I just didn't send JSESSIONID from my flash-application by request.