11 Replies Latest reply on Mar 22, 2007 12:31 PM by Rob Jellinghaus

    GWT and Seam: progress, setbacks

    Rob Jellinghaus Novice

      With Jason DeTiberus's help, I've made some forward progress on further integration of GWT and Seam. I've integrated the a4j-gwtKickStart HelloWidget into the Seam booking example.

      That integration is available here: http://unrealities.com/g4jsf-seam.html

      I will post the readme.txt from that example, describing the current situation and the current problem, in a moment. All help, especially from the ajax4jsf guys, would be very much appreciated... I'm not experienced enough with facelets to know where to go from here.

      Thanks,
      Rob


        • 1. Re: GWT and Seam: progress, setbacks
          Rob Jellinghaus Novice

          Here's the readme from the sample above. Please read and assist if you can. Thanks!

          REVISED EXAMPLE INTEGRATING GWT (OR ATTEMPTING TO)
          ==================================================
          Rob Jellinghaus, rjellinghaus at gmail dot com

          This example is the Seam 1.2.0-PATCH1 booking example, with the a4j-gwtKickStart example rudely glued into it. The only purpose here is to sort out very basic bugs integrating GWT, g4jsf, and Seam.

          The example integrates patches to GWT and to g4jsf to allow invocation of
          arbitrary service interfaces. The patched GWT and g4jsf libraries are included.

          This example has been tested only under Tomcat (I don't have JBoss installed).

          To run it:

          - Edit the build.properties file to point at your local Seam installation and
          tomcat base directory
          - Run "ant clean deploy.tomcat.jsf12" to build the entire app and deploy to Tomcat

          The problem:

          The app builds fine, and comes up OK, instantiating the JSF page. However, the GWT widget (the HelloWidget) in the page is not visible. It is definitely getting instantiated, but its HTML is not being installed properly.

          I suspect this is because I am not sure how to manage the interaction between gwt:page and ui:composition. I have gwt:page in home.xhtml (since home.xhtml is the root view, essentially), and I have widget:helloWidget in main.xhtml. It seems that this somehow confuses g4jsf and fails to configure gwt.js properly. I am not sure if there are any g4jsf examples that use multiple facelets views with ui:composition, so I'm not sure if this is a simple error on my part, or a fundamental issue with the current version of g4jsf.

          In any case, all support very much appreciated.

          Thanks to Jason DeTiberus for sorting out a collision between GwtPhaseListener and SeamPhaseListener, and for providing the (included) GwtSeamPhaseListener class.

          Cheers!
          Rob



          References:

          Patch to GWT 1.3.3 to support more flexible RPC:
          http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/thread/ebdc86452e6b8d36

          Patch to g4jsf to allow invocation of general interfaces on JSF managed beans:
          https://ajax4jsf.dev.java.net/servlets/ReadMsg?list=dev&msgNo=186

          Thread on g4jsf / Seam integration on the Ajax4JSF dev forum on JBoss:
          http://www.jboss.com/index.html?module=bb&op=viewtopic&t=103603

          • 2. Re: GWT and Seam: progress, setbacks
            Rob Jellinghaus Novice

            Jason DeTiberus mentions in private mail that the problem is definitely ui:composition. ui:composition breaks G4JSF, basically. My sample above demonstrates this. He's game to produce a smaller sample that shows the problem.

            Incidentally, my sample above embeds the widget:HelloWidget at the top of main.xhtml (the main hotel search page in the demo) -- looking at main.xhtml you'll clearly see it, and looking at the rendered page's source (once you run the demo), you'll see tags that are being emitted by G4JSF but that are not rendering via GWT.

            Thanks again for any assistance. I know Sergey got the demo working last Thursday night, but was confused that he couldn't see anything (which is, of course, the problem! ;-).

            • 3. Re: GWT and Seam: progress, setbacks
              Sergey Smirnov Master

              The application looks like the standard Booking Demo available from Seam site.

              If it looks the same and does the same, why one needs to learn new technology? I.e. I did not see something that impressed me.

              Yes, the source code in the browser window looks different. The difference itself is not a benefit yet. The benefits shown clearly are still missing.

              • 4. Re: GWT and Seam: progress, setbacks
                Rob Jellinghaus Novice

                Sergey, we are failing to communicate here.

                I was making this example be deliberately uninteresting in order to see whether something incredibly simple -- namely, including one of G4JSF's OWN SAMPLE WIDGETS in a pre-existing Seam example -- would work.

                IT DOES NOT WORK. This example clearly shows a BUG in G4JSF -- G4JSF is totally broken with Facelets ui:composition.

                I did not WANT to bother making an interesting example until I knew whether the basic stuff worked. And I did the right thing, because the basic stuff is broken!

                I agree and admit that putting the HelloWidget into the booking example is silly... except as a way to find bugs that prevent doing anything better.

                So the question now is: is Ajax4JSF team interested in fixing G4JSF so that it works with ui:composition (e.g. so it works in anything other than trivial one-page applications)?

                Please let me know, so I know whether to bother doing any further work with G4JSF. If we can work together on fixing G4JSF, then I will definitely work on an example that actually uses GWT in an interesting way. That is my plan! And I know this is not it, yet! But until we can get this uninteresting example working, there is no way to proceed on the interesting example.

                Are we communicating yet?

                Thank you,
                Rob

                • 5. Re: GWT and Seam: progress, setbacks
                  Sergey Smirnov Master

                  If it is a bug, put in jira. If you know how to fix it, fix it and mark the bug as resolved.

                  • 6. Re: GWT and Seam: progress, setbacks
                    Rob Jellinghaus Novice

                    Done: http://jira.jboss.com/jira/browse/AJSF-13

                    Jason and I will work on a simpler example, though I expect you guys could easily produce one. Feel free to use my Seam example as a starting point, also.

                    I do not know how to fix it.

                    • 7. Re: GWT and Seam: progress, setbacks
                      Rob Jellinghaus Novice

                      OK, I owe Sergey an apology for having accused g4jsf of being buggy. Sergey, I am sorry I flamed you in the post above.

                      More investigation into the problem shows that there are several issues with the way I was configuring my sample. gwt:page is picky about where it goes, and I had not merged the code properly with the Facelets pages from the Seam example.

                      I am now actively fixing up the problems with my example, and some things are starting to work.

                      I have had to make more patches to g4jsf in the process. For example, I had to get gwt:page to emit an xmlns="http://www.w3.org/1999/xhtml" attribute on the element it writes; otherwise, JSF refuses to return the right content type to the browser (the browser renders the page as XML, not as HTML).

                      Right now, the problem is that "/jboss-seam-booking/faces/gwt/gwt.js" is returning a 404 error, indicating that g4jsf's expectations about servlet mappings are being violated by the Seam web.xml. I may time out before fixing that tonight, though (it's already 1:30 am and my baby daughter wakes up at 6 am every day!).

                      I will hopefully wind up with a patch for all these Seam compatibility issues, which I will submit along with my other g4jsf patches once GWT 1.4rc1 ships.

                      I do take exception to being told that I am failing to impress you, when I'm putting hours of my own time into fixing basic issues that block using g4jsf (a JBoss project) with Seam (another JBoss project). But I suppose I will have to live with being unimpressive ;-) ...at least until I fix these bugs, and then do an example that's supposed to impress you!

                      • 8. Re: GWT and Seam: progress, setbacks
                        Igor Shabalov Apprentice

                        Rob, please update status of http://jira.jboss.com/jira/browse/AJSF-13
                        after you have more understanding what is wrong.

                        • 9. Re: GWT and Seam: progress, setbacks
                          Jason DeTiberus Newbie

                          I've figured out where Rob and myself had strayed on this. The g4jsf code was doing what it was supposed to, but because of a lack of examples using facelets composition we did not have the proper tags in the proper places.

                          Instead of plain html, head, and body tags in the template page, there must be a <f:view> and a <gwt:page> tag in the template. After that, g4jsf and facelets composition works like a champ.

                          <!-- example Template.xhtml -->
                          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                          <f:view xmlns:ui="http://java.sun.com/jsf/facelets"
                           xmlns:gwt="https://ajax4jsf.dev.java.net/gwt"
                           xmlns:f="http://java.sun.com/jsf/core"
                           contentType="text/html">
                           <gwt:page>
                           <h1>G4JSF and Seam with Facelets Composition</h1>
                           <p><ui:insert name="body"/></p>
                           </gwt:page>
                          </f:view>
                          
                          <!-- example composition page -->
                          <ui:composition template="Template.xhtml"
                           xmlns:gwt="https://ajax4jsf.dev.java.net/gwt"
                           xmlns:widget="https://ajax4jsf.dev.java.net/gwt/GwtSeam"
                           xmlns:ui="http://java.sun.com/jsf/facelets"
                           contentType="text/html">
                           <ui:define name="body">
                           <gwt:page>
                           <widget:component id="main" buttonLabel ="Say Hello To Me!" greeting="Hello From #{greetingBean.name}!">
                           <gwt:gwtListener method="#{greetingBean.takeGreeting}"
                           event = "gwtseamtest.g4jsf.client.testwidget.TestEvent"/>
                           </widget:component>
                           </gwt:page>
                           </ui:define>
                          </ui:composition>


                          • 10. Re: GWT and Seam: progress, setbacks
                            Rob Jellinghaus Novice

                            Done. I have closed the issue as 'rejected' -- Jason DeTiberus and I have independently gotten it working. It was simple misunderstanding of how to use the gwt:page tag (it must replace the outermost and tags in the template.xhtml or equivaelnt file).

                            • 11. Re: GWT and Seam: progress, setbacks
                              Rob Jellinghaus Novice

                              The above should say "it should replace the outermost < html > and < head > tags in the template.xhtml or equivalent file."