You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 26 Members of 4063 |
| Forum: Seam Users |
09. Jul 2008, 20:07 CET | Link |
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
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...
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.
Dan Allen | mojavelinux.com | Author of Seam in Action
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 seam . Nice work!
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,
I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death.
Erm, I think it can... Take a look at the remoting examples, they deploy as WARs to tomcat.
Read about how to report a bug.
Hi!
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,
I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death.
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!
Read about how to report a bug.
Hi!
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.
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.
I seems someone else is already trying that, but, they seem to believe that:
I really hope that is not true...
Regards,
I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death.
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 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.
Read about how to report a bug.
Hi!
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.
Okey, got it. Will try to actively help.
Again sorry for wasting your time.
Regards,
I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death.