7 Replies Latest reply on Mar 16, 2008 4:07 PM by eirirlar

    accessing natural conversation when not logged in

    mars1412 Apprentice

      I am using a natural conversation on a page that requires the user to login.


      if the user is logged in and directly accesses the URL (e.g.http://localhost:8080/prj/edit.seam?webUserId=2), everything's ok.


      but if the user is not logged in yet and accesses the URL, the view will be captured - the user taken to the login page and after authentication he is redirected to the captured view.
      In this case I get an errormessage:



      Caused by javax.servlet.ServletException with message: "#{identity.login}: 
      javax.el.ELException: java.lang.IllegalStateException: 
      conversation id evaluated to null: Conv_EditWebUser"



      pages.xml: natural conversation definition:


           <conversation name="Conv_EditWebUser"
                          parameter-name="webUserId"
                          parameter-value="#{webUserHome.webUserId}"/>
      



      Any ideas what the problem might be?
      Does any one else also have this problem?


      I am using seam 2.0.1.GA
      edit.page.xml file: login-ceck, conversation handling, page-parameter


      <page xmlns="http://jboss.com/products/seam/pages"
            ...
            login-required="true"
            conversation="Conv_EditWebUser">
      
           <begin-conversation join="true" />
           
           <param name="webUserId" value="#{webUserHome.webUserId}"/>
            ...
      



      as you can see, the webUserId (which is passed as a URL parameter) is used as the natural conversation id.


        • 1. Re: accessing natural conversation when not logged in
          eirirlar Newbie

          Disclaimer: this answer is based on what I've learned trying to get natural conversations to work.


          I don't think you're supposed to specify the conversation's parameter name and value as a page paramater; when you specify that you're using a natural conversation the natural conversation will take care of getting the parameter value from the el-expression, so just make sure webUserHome is in scope.


          The other thing is that I think you have to start the natural conversation before you redirect to a page that uses a natural conversation. When you do so you say <begin-conversation join="true" conversation="Conv_EditWebUser"/>


          Hope it helps. And if you manage to redirect to an existing natural conversation, please let me know :)


          • 2. Re: accessing natural conversation when not logged in
            mars1412 Apprentice

            I don't think you're supposed to specify the conversation's parameter name and value as a page paramater;

            I can't drop the page parameter, because this statement initializes my EntityHome


            @Name("webUserHome")
            @Scope(ScopeType.CONVERSATION)
            public class WebUserHome extends EntityHome<WebUser> {
            
                 public void setWebUserId(Long id) {
                      setId(id);
                 }
            
            
            



            should I use another name fot he page-parameter (like ?webUserId=2&initWebUserId=2)?
            this does not seem to be reasonable..



            The other thing is that I think you have to start the natural conversation before you redirect to a page that uses a natural conversation.

            <begin-conversation join="true" conversation="Conv_EditWebUser"/>





            When I add the conversation attribute also to the begin-conversation tag, I get the same error.


            My problem here is, that the natural conversation is not existing and I cannot directly control the redirect.


            I'm not sure, if bookmarking a login-required page works at all.
            The seam-bay example has the same problem.
            If I directly access the bid.xhtml page (http://localhost:8080/seam-bay/bid.seam?auctionId=62748261 which is also used as an example in the docs: Redirecting to a natural conversation
            I see the same errormessage.
            (ok, this page is not desinged to be accessed directly, but anyway - when you access it directly after login, it works: means, the page is empty, but there is no excpetion

            • 3. Re: accessing natural conversation when not logged in
              Jacob Orshalick Apprentice

              Martin, I believe you may be running into JBSEAM-2449.  This would seem to be a fairly common issue when using natural conversations on pages that a login is required.  Your approach seems reasonable to me.



              I don't think you're supposed to specify the conversation's parameter name and value as a page paramater;

              You actually can do this and it allows bookmarking since the conversation is started with page access (although, if you are not logged in this could lead to the issue Martin is describing).



              The other thing is that I think you have to start the natural conversation before you redirect to a page that uses a natural conversation.

              This is not required.  You can start the natural conversation when the page is accessed.



              And if you manage to redirect to an existing natural conversation, please let me know

              This issue is reported at JBSEAM-2606 but if you use the approach Martin is taking, you will be able to join an existing conversation without issue (the redirect is the problem at the moment).  Each of these approaches will be covered in detail in the new JBoss Seam book which should be on Safari any day now ;)

              • 4. Re: accessing natural conversation when not logged in
                Jacob Orshalick Apprentice

                By the way, if you are looking for a workaround on the redirect issue, check out the source for the Natural Hotel Booking example at the preview chapter examples.  This uses an approach that allows you to resume a natural conversation on redirect at the point where the conversation left off.


                Hope that helps.

                • 5. Re: accessing natural conversation when not logged in
                  mars1412 Apprentice

                  tx jacob


                  looking forward to reading your book..

                  • 6. Re: accessing natural conversation when not logged in
                    eirirlar Newbie

                    Jacob, I used your examples as a template for my application and it works quite well. Thanks a lot!


                    A question regarding your example: I have a use case where I want to join an existing conversation, but not navigate to the same place I left off that conversation. ConversationEntry.select(); doesn't work in this case - any hints on how to do this?

                    • 7. Re: accessing natural conversation when not logged in
                      eirirlar Newbie

                      Eirik Larsen wrote on Mar 15, 2008 03:17 PM:

                      A question regarding your example: I have a use case where I want to join an existing conversation, but not navigate to the same place I left off that conversation. ConversationEntry.select(); doesn't work in this case - any hints on how to do this?


                      Found an ok-ish way to do it for those who might be interrested:


                                     Manager.instance().redirect("/anotherpage.xhtml",
                                               "YourNaturalConversationName:" + componentThatProvidesNaturalConversationId.getId());