5 Replies Latest reply on Mar 30, 2007 5:07 AM by fhh

    keeping context using external webapp

    Oliver Charlet Newbie

      Hi there,

      I want to integrate an external payment system into my seam application. What would be the best way to keep the conversational context?
      I can call the payment server using a POST request, but it is answering only using a GET.
      I suppose I have to send somekind of id with the request, that can be returned even using a GET call, but does that have to be the java session id, or some seam internal id, like the "cid", that shows up on get requests?

      Thanks for any help
      :ollix

        • 1. Re: keeping context using external webapp
          Gavin King Master

          Wrap your servlet in the ContextFilter, and pass the conversation id in a request parameter called "conversationId", or whatever you set it to be in components.xml.

          • 2. Re: keeping context using external webapp
            Oliver Charlet Newbie

            gavin,

            the problem is more complicated.
            the payment server by contract reads my callback page, parses it to enter some payment provider specific information and displays it.
            That means, that my server gets no jsessionId from that payment server and thus cannot assign the request to the correct session. the solution, of course is to send the jsessionId explictily to the payment server and create a callback URL that contains it ala ".../callback.seam;jsessionId=xxx?cid=3".
            My problem now is how to programmatically retrieve the current jsessionId inside a helper bean.
            Can you give me a hint how to get a hold on that id?

            Thanks a lot
            :ollix

            • 3. Re: keeping context using external webapp
              Oliver Charlet Newbie

              ok, i found a solution. not very elegant, but it works.

              @Name("jsessionId")
              public class SessionIdHelper {
              
               @Override
               public String toString() {
               return ((HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest()).getSession().getId();
               }
              
              }
              


              • 4. Re: keeping context using external webapp
                Oliver Charlet Newbie

                just in case someone needs to do the same, I wrap up my last post.

                I created that ugly helper, to enable to use the web container's jsessionid. I use it to create a simple link, that contains both the jsessionid and the conversation id. The remote server uses this information to setup a callback URL :

                .../callback.seam;#{jsessionId}?cid=#(cid)...

                The cid component is a second ugly helper, that returns the current conversationId:
                @Name("cid")
                public class ConversationIdHelper {
                
                 @Override
                 public String toString() {
                 return Conversation.instance().getId();
                 }
                
                }
                

                The remote server calls this URL, retrieves the resulting HTML and injects some payment information using predefined provider specific tags. The resulting HTML is than represented to the user. The URL seen by the user will be a payment provider one, but the content looks just like the stuff from our website. The only "problem" left is the need to use absolute URLs for all Images, stylesheets etc. I used a second template for this.

                If somebody knows a more elegant way to do the same, I would be happy to get some feedback.

                • 5. Re: keeping context using external webapp
                  fhh Expert

                   


                  The cid component is a second ugly helper, that returns the current conversationId


                  That functionality is already built into Seam. Check the examples.

                  Regards

                  Felix

                  BTW: Have a look at @Unwrap. It wcould simplify your code.