3 Replies Latest reply on Aug 13, 2009 4:14 AM by kapitanpetko

    Is it possible to outject from a servlet?

    ryankimber

      I have a fillable PDF form with an action button that uploads the completed form (as FDF or PDF). I'm able to upload to a servlet with no problem. The PDF is displayed inline using the IceFaces media tag in a displayPDF.xhtml.


      I'd like the servlet to be able to modify some of the values in the conversation and session scopes. Is there a way to outject from a servlet? I'm able to retrieve components using Component.getInstance(componentName), but is there a way to replace values?


      Alternatively, can I upload to Seam without having the JSF front-end?


      Thank you for any guidance you can offer.

        • 1. Re: Is it possible to outject from a servlet?
          kapitanpetko

          Ryan Kimber wrote on Aug 12, 2009 03:58:


          I'd like the servlet to be able to modify some of the values in the conversation and session scopes. Is there a way to outject from a servlet? I'm able to retrieve components using Component.getInstance(componentName), but is there a way to replace values?


          There are ways to make your servlet conversation aware (Cf. 30.1.4.8. Context management for custom servlets) if you really need it.
          You can set attributes in request and session scope using the regular Servlet API's. Conetxts.getSessionContext().set(), etc. are simply wrappers for those, should give you the same result.



          Alternatively, can I upload to Seam without having the JSF front-end?



          Sure, but you have to write the servlet yourself (just post your multipart data to your servlet).
          There is some stuff for this from Apache (commons?) and Spring as well. You might want to look into these.


          HTH

          • 2. Re: Is it possible to outject from a servlet?
            ryankimber

            Thanks Nikolay.


            I've written a servlet that's using the web context filter (web:context-filter url-pattern="/SaveOrSubmitServlet/*"), and I'm able to retrieve one of my action components from Component.getInstance(), however, when I call a method on the action class, I get an IllegalStateException - no active event context.


            I'm passing the conversation id to the servlet - I've tried using both cid and conversationId (cid is what's set in my components.xml).


            I've updated all my Seam jars to 2.2.0GA versions, but I'm still getting this error.


            If I've passed the conversation ID on properly, this shouldn't be a problem, should it?
            Does anyone have any ideas? Are there limits on what I can do within my action component? (This action component stores a PDF in the Document Manager and sets a session scoped pdfLink string used to retrieve the PDF in my JSF view).

            • 3. Re: Is it possible to outject from a servlet?
              kapitanpetko

              Ryan Kimber wrote on Aug 12, 2009 17:33:


              If I've passed the conversation ID on properly, this shouldn't be a problem, should it?



              Should work, yes. How are you setting the cid for your request? If all else fails, try to debug it :)
              Set a breakpoint in ContextualServeltRequest.restoreConversationId and check what happens.


              HTH