10 Replies Latest reply on Jul 12, 2008 11:27 PM by Francisco Jose Peredo Noguez

    When to use each method of Seam remoting

    Justin S. Newbie

      I've been searching for an answer, or set of best practices, on when it's best to use each of the seam remoting methods; a4j, @WebRemote, EL, etc... Has anyone come across such an answer or can provide a rough outline?


      In particular I'm currently struggling with which method is recommended when trying to populate an ExtJS GridPanel with the results of a Entity query resultList.


      Thanks,


      - Justin

        • 1. Re: When to use each method of Seam remoting
          System Administrator Expert

          Seam remoting is used to call a business component method (typically a SLSB or SFSB) from a javascript funtion via AJAX.


          Read chapter 21 of the Seam 2.0.x ref doc for more info on Seam remoting. @WebRemote is a Seam annotation to expose an EJB method to be called remoted via AJAX.


          Here's an example:


          @Local
          public interface HelloLocal {
          @WebRemote
          public String sayHello(String name);
          }



          a4j refers to ajax4jsf which JBoss purchased from Exadel and is now part of Richfaces.  They're basically UI component tags that you embed in JSF pages.


          EL typically refers to expression language and in the Seam application scenarios typically refers to JSF EL. 


          Ext JS is a javascript library but I've never used it.  Most likely there is a Richfaces equivalent for it.


          I don't use Seam remoting unless I have to b/c you have the XML and serialization/deserialization overhead with AJAX calls.


          Typically stick with JSF EL action method and getter/setter calls unless you must access a business component from inside a javascript function.


          I'm thinking in your case with ExtJS library, you can only use those components and those won't be able to modify the code.


          Think about using Richfaces instead, it's part of the JBoss stack, unless Richfaces is missing some functionality that you need...



          • 2. Re: When to use each method of Seam remoting
            Dan Allen Master

            Ajax4jsf/RichFaces is specific to JSF and won't be useful unless JSF is your presentation framework. Ajax4jsf offers the a4j:function tag which is comparable to the @WebRemote except it invokes the JSF life cycle, where as @WebRemote uses the Seam resource servlet.


            @WebRemote is about lightweight communication with server. It can certainly be used to grab information for the ExtJS panel grid and I have actually used it. However, you don't get back JSON, rather objects, so you have use a custom data provider in ExtJS. But is isn't provided out of the box. Search for DWR examples and you then have to port them to Seam Remoting.

            • 3. Re: When to use each method of Seam remoting
              Justin S. Newbie

              Thanks Dan, that clarifies what I was thinking. I've actually already found a great library written for Ext that provides a Seam Remoting JSON store. Now I just need to figure out what's the best way to hook everything up.


              BTW: reading through an advance copy of your Seam in Action book and its leaps and bounds better than the official seam documentation. Nice work!

              • 4. Re: When to use each method of Seam remoting
                Francisco Jose Peredo Noguez Master

                Hi!


                I think it also depends on the kind of project you are building AFAIK @WebRemote can only be used if you project is an EAR (an option I particularly don't like because its deployment is slow and therefore it slows down development).


                On the other hand a4j:function works in a WAR deployment (and also on an EAR deployment) therefore IMO a4j is the lightweight option (you can use it even if you choose to deploy in Tomcat) since it doesn't require the use of EJB.


                Regards,

                • 5. Re: When to use each method of Seam remoting
                  Pete Muir Master

                  Francisco Peredo wrote on Jul 11, 2008 19:19:


                  I think it also depends on the kind of project you are building AFAIK @WebRemote can only be used if you project is an EAR (an option I particularly don't like because its deployment is slow and therefore it slows down development).



                  Erm, I think it can... Take a look at the remoting examples, they deploy as WARs to tomcat.

                  • 6. Re: When to use each method of Seam remoting
                    Francisco Jose Peredo Noguez Master

                    Hi!



                    Pete Muir wrote on Jul 11, 2008 19:24:



                    Francisco Peredo wrote on Jul 11, 2008 19:19:


                    I think it also depends on the kind of project you are building AFAIK @WebRemote can only be used if you project is an EAR (an option I particularly don't like because its deployment is slow and therefore it slows down development).



                    Erm, I think it can... Take a look at the remoting examples, they deploy as WARs to tomcat.


                    They do? to plain old tomcat 6? in POJOs? AFAIK they shouldn't even compile because tomcat lacks javax.ejb.* I tought they only worked with Tomcat+Jboss Embedded (BTW without a new release since (2008-01-21 19:30))


                    Tomcat+Jboss Embedded is IMHO a flawed combination because multiple deployments do not work... is that no longer true?


                    Regards,

                    • 7. Re: When to use each method of Seam remoting
                      Pete Muir Master

                      You are confusing @javax.ejb.Remote and @org.jboss.seam.annotations.remoting.WebRemote AFAICT.


                      I don't think there has been a fix to multiple deployments not working.


                      BTW we need a new maintainer for Embedded JBoss, specifically we could really do with a Emebedded CR1 based on JBoss 5 CR1 - well volunteered!


                      • 8. Re: When to use each method of Seam remoting
                        Francisco Jose Peredo Noguez Master

                        Hi!




                        Pete Muir wrote on Jul 12, 2008 20:40:


                        You are confusing @javax.ejb.Remote and @org.jboss.seam.annotations.remoting.WebRemote AFAICT.


                        I mean @org.jboss.seam.annotations.remoting.WebRemote, all examples I have seen with use it in combination with javax.ejb.Local and javax.ejb.Stateful and those annotations are not included in Plain Old Tomcat 6 you need Embedded JBoss for those.




                        I don't think there has been a fix to multiple deployments not working.



                        Well, someone (logicicle) posted saying he found the way, just tell where to find this line: <attribute name="Isolated">true</attribute> and that's it.



                        BTW we need a new maintainer for Embedded JBoss, specifically we could really do with a Emebedded CR1 based on JBoss 5 CR1 - well volunteered!



                        I seems someone else is already trying that, but, they seem to believe that:




                        [...] it seems that nobody at JBoss cares since Embedded mode is not a priority.



                        I really hope that is not true...


                        Regards,



                        • 9. Re: When to use each method of Seam remoting
                          Pete Muir Master

                          Francisco Peredo wrote on Jul 12, 2008 21:26:


                          I mean @org.jboss.seam.annotations.remoting.WebRemote, all examples I have seen with use it in combination with javax.ejb.Local and javax.ejb.Stateful and those annotations are not included in Plain Old Tomcat 6 you need Embedded JBoss for those.



                          Did you bother trying with just a Seam POJO before making this (unfounded) assertion? Or perhaps take a look at the source code? Or, hell, even take a look at the documentation where it explicitly states you can use Seam Remoting with POJOs? I suspect not.




                          I seems someone else is already trying that, but, they seem to believe that:



                          [...] it seems that nobody at JBoss cares since Embedded mode is not a priority.




                          I see nobody making an effort to fix the problem in that thread, just people pontificating, which gets very boring fast. On JBoss projects doers are respected, not those who make noise. So again, I invite you to do something and reduce, rather than increase, the signal to noise ratio.

                          • 10. Re: When to use each method of Seam remoting
                            Francisco Jose Peredo Noguez Master

                            Hi!




                            Pete Muir wrote on Jul 12, 2008 21:52:


                            Did you bother trying with just a Seam POJO before making this (unfounded) assertion? Or perhaps take a look at the source code? Or, hell, even take a look at the documentation where it explicitly states you can use Seam Remoting with POJOs? I suspect not.



                            I went to the examples directory, I couldn't find an POJO example, and I did try to find an example without javax.ejb.* and couldnt find it progressbar, or in  helloworld, or in chatroom... mmm, i didn't check gwt... after all I am not interested in using gwt...mmmm...let see...allright, I am ashamed now... I am sorry... it does not use javax.ejb.*. I am really truly sorry.




                            I see nobody making an effort to fix the problem in that thread, just people pontificating, which gets very boring fast. On JBoss projects doers are respected, not those who make noise. So again, I invite you to do something and reduce, rather than increase, the signal to noise ratio.



                            Okey, got it. Will try to actively help.


                            Again sorry for wasting your time.


                            Regards,