6 Replies Latest reply on Jun 7, 2009 6:21 PM by Ronald van Kuijk

    Seam and Servlets?

    Greg Zoller Newbie

      Does anyone have an example of a simple servlet that can access Seam's contexts?


      I've looked at a bunch of postings and tried wrapping my servlet request using ContextualHttpServletRequest, and a bunch of other things.  Nothing seems to work.  I get the infamous error others have got:


      java.lang.IllegalStateException: No active event context
           at org.jboss.seam.core.Manager.instance(Manager.java:368)
           at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:55)
      



      I'm trying to use this servlet w/a facelets include in a page:


      <ui:include src="/tablerows/reallyBigTable"/>
      
      



      I have the servlet set up in web.xml (works fine if I remove any Seam-related stuff).  I've also added this line to components.xml:


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



      My last attempted servlet code (which blows up):




      public class BigTableServlet extends HttpServlet {
          @Override
           public void doGet(final HttpServletRequest request, final HttpServletResponse response) 
               throws ServletException, IOException {
              new ContextualHttpServletRequest(request) {
                  @Override
                  public void process() throws IOException {
                          Object scroller = Component.getInstance("lineScroller");  // lineScroller is a paged-scoped Seam component
                         PrintWriter out = response.getWriter();
                         if( scroller == null )
                              out.println("<div>Hello World No Scroller</div>");
                         else
                              out.println("<div>Hello World Scroller Found!</div>");
                  }
              }.run();
          }
      }



      Many thanks for any ideas!
      Greg