7 Replies Latest reply on Feb 15, 2011 8:11 AM by joergi

    [solved] Problems with EL in JavaScript by Seam Remoting

    joergi

      Hi.
      i used the search and i have not found an answer...

       

      We use Seam 2.2.0 GA in our project.

       

      on the first page i outject an object. (Scope Type is CONVERSATION)
      On the next page the object is still there.

       

      But if i use Seam Remoting i can't reach the object.

       

      i read in the documentation and in the forum, that i should use this code part:

       

      Seam.Remoting.getContext().setConversationId( #{conversation.id} );

       

      I put that part in my Javascript file, but now i have the problem, that JavaScript is not working correctly.
      Firebug also says that " #{conversation.id} " is not valid.

       

      (before i inserted "Seam.Remoting.getContext().setConversationId( #{conversation.id} );  " seam remoting was perfectly working)
      Can anyone tell me, what i forgot?

        • 1. Re: Problems with EL in JavaScript by Seam Remoting
          antibrumm.mfrey0.bluewin.ch

          Hi,


          I've never used remoting yet but are you talking about a .js file? I would be quite surprised if seam/jsf does handle expressions in these kind of files.


          I would try to put this code in your page and see whats happening. Most probably your .js file contains the  #{conversation.id} as code on the client side, which means nothing in Javascript.


          Martin

          • 2. Re: Problems with EL in JavaScript by Seam Remoting
            joergi

            Hi Martin,
            thanks for your response.


            I did exactly what was in the documentation:
            Put this into your JavaScript.


            Thats where I'm calling the Seam Remoting.


            I was also wondering that EL should work at this position,  but that's how i understood the documentation.


            Thanks.
            Joergi

            • 3. Re: Problems with EL in JavaScript by Seam Remoting
              joergi
              Link to the Forum:
              http://docs.jboss.org/seam/2.2.0.GA/reference/en-US/html/remoting.html#d0e22747

              This small snippet of JavaScript will set the conversation ID that is used for remoting calls to the current view's conversation ID:
              Seam.Remoting.getContext().setConversationId( #{conversation.id} );

              • 4. Re: Problems with EL in JavaScript by Seam Remoting
                shane.bryzak

                Just to clarify, you are including this JavaScript inside a JSF page, right? 

                • 5. Re: Problems with EL in JavaScript by Seam Remoting
                  joergi
                  Hi Shane,

                  No, i have a (400 line big) JavaScript file, where i call this:

                  function getAllNonBusinessDays() {
                  //     alert(Seam.Remoting.getContext().getConversationId());
                      Seam.Remoting.getContext().setConversationId( #{conversation.id} );
                      Seam.Component.getInstance("schedulerSeamRemoteManager").getAllNonBusinessDays(reloadNonBusinessDaysView);
                  }

                  (this is only one example, i have more of seam remote requests in this JavaScript file)

                  without  "Seam.Remoting.getContext().setConversationId( #{conversation.id} ); "  this it's totally working...
                  (but i need this now...)

                  The JavaScript file is loaded into a JSF-page...

                  • 6. Re: Problems with EL in JavaScript by Seam Remoting
                    shane.bryzak

                    Well of course that's not going to work, as you have no EL interpolator to replace the expression with the actual conversation ID (the documentation assumes you know this).  Try setting the conversation ID in your JSF code - you can store it in a variable if that makes it more preferable (do this before the line where you import your JS file):




                    var conversationId = #{conversation.id};






                    Then in your JavaScript, use:




                    Seam.Remoting.getContext().setConversationId(conversationId);



                    • 7. Re: Problems with EL in JavaScript by Seam Remoting
                      joergi

                      Thanks a lot   ;)


                      works perfect now!