Question

I am trying to integrate GWT with SEAM. i followed the Docs and tried to run the

example as follows.

  1. I created a GWT project, using Eclipse Galileo and created the classes as given in the example

  2. I then added the Seam 2.0.2 jars to the build path

  3. I compiled the application, using Google GWT Compiler using the eclipse UI.

  4. Finally i ran the application.

First I would like to know whether the above steps are correct. After running the application I do not get the desired result.

Also is this the only way to integrate GWT with Seam ?

Update

I have got this example running using ant. But the aim of my exercise will be to run it via eclipse ui.

I created my own project by name GWTTest and tried to recreate the example in the Eclipse

UI. There are a few things that I have noticed. GWT Compile via Eclipse UI creates a directory by name gwttest inside the war file. Where as the directory structure created by ant is different.

In the example there is a piece of code in AskQuestionWidget getService functions as follows

String endpointURL = GWT.getModuleBaseURL() + "seam/resource/gwt";

How do I modify this code to suit my directory structure ?

Was it helpful?

Solution

We use seam+richfaces+gwt and it works very well. Although we build everything with maven, I suppose you can use ant as well. The general idea is to start the whole web application in GWT Development Mode. You don't have to compile everything (which takes a long time in case of GWT compiler). Development mode will compile requested resources on demand. By running GWT application this way, you can also debug client side code.

It is also possible to call GWT methods in response to seam actions.

Update:

I can elaborate on our solution a bit:

Maven

Your project should be configured with packaging: war. There are some official instructions on setting seam with maven (also richfaces):

http://docs.jboss.org/seam/2.2.1.CR2/reference/en-US/html/dependencies.html#d0e34791

http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/SettingsForDifferentEnvironments.html

For GWT add following sections to your pom.xml:

<dependency>
  <groupId>com.google.gwt</groupId>
  <artifactId>gwt-user</artifactId>
  <version>2.1.0</version>
  <scope>provided</scope> <!-- prevents from including this in war -->
</dependency>
<dependency>
  <groupId>com.google.gwt</groupId>
  <artifactId>gwt-dev</artifactId>
  <version>2.1.0</version>
  <scope>provided</scope> <!-- prevents from including this in war -->
</dependency>
<dependency>
  <groupId>pl.ncdc.gwt</groupId>
  <artifactId>gwt-servlet-war</artifactId>
  <version>2.1.0</version>
  <type>war</type> <!-- adds gwt-servlet.jar to your war, but not to your classpath -->
</dependency>

<!-- build section -->
<build>
  <resources>
    <resource>
      <directory>src/main/resources</directory>
    </resource>
    <resource>
      <directory>src/main/java</directory>
      <includes>
        <include>**/client/**/*.java</include>
        <include>**/client/**/*.properties</include>
        <include>**/shared/**/*.java</include>
        <include>**/shared/**/*.properties</include>
        <include>**/*.gwt.xml</include>
      </includes>
    </resource>
  </resources>
  <testResources>
    <testResource>
      <directory>src/test/java</directory>
      <includes>
        <include>**/client/**/*.java</include>
        <include>**/client/**/*.properties</include>
        <include>**/shared/**/*.java</include>
        <include>**/shared/**/*.properties</include>
        <include>**/*.gwt.xml</include>
      </includes>
    </testResource>
  </testResources>
<plugins>
  <plugin> <!-- dirty hack for GWT issue #3439 - it is not really fixed -->
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
      <execution>
        <id>remove-javax</id>
        <phase>compile</phase>
        <configuration>
          <tasks>
            <delete dir="${project.build.directory}/classes/javax" />
          </tasks>
        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>gwt-maven-plugin</artifactId>
    <version>1.3.2.google</version>
    <configuration>
      <extraJvmArgs>-Xmx512M</extraJvmArgs>
      <gwtVersion>${gwt.version}</gwtVersion>
      <modules>
        <module>com.company.gwt.project.module.Module</module>
      </modules>
      <soyc>false</soyc>
      <draftCompile>${gwt.draft.compile}</draftCompile> <!-- you can control this with profiles -->
      <localWorkers>2</localWorkers><!-- in theory should speed things up on our quad CPU hudson -->
      <style>${gwt.style}</style> <!-- you can control this with profiles -->
    </configuration>
    <executions>
      <execution>
        <id>compile</id>
        <phase>prepare-package</phase>
        <goals>
          <goal>compile</goal>
        </goals>
      </execution>
      <execution>
        <id>gwt-test</id>
        <phase>integration-test</phase>
        <goals>
          <goal>test</goal>
        </goals>
        <configuration>
          <includes>**/*GwtTestSuite.java</includes>
        </configuration>
      </execution>
    </executions>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1</version>
    <configuration>
      <archiveClasses>true</archiveClasses>
      <warSourceDirectory>src/main/webapp-empty</warSourceDirectory> <!-- just empty dir for workaround -->
      <webResources>
        <resource>
          <directory>src/main/webapp</directory>
          <excludes>
            <exclude>app.*</exclude> <!-- name of you gwt module(s) - rename-to in gwt.xml -->
            <exclude>WEB-INF/web.xml</exclude>
          </excludes>
        </resource>
        <resource>
          <directory>src/main/webapp</directory>
          <includes>
            <include>WEB-INF/web.xml</include>
          </includes>
          <filtering>true</filtering>
        </resource>
      </webResources>
    </configuration>
  </plugin>
</plugins>
</build>

This configuration should produce war with both - seam and gwt compiled. If you want to use such project in development mode put also this in pom.xml:

<dependency>
  <groupId>com.xemantic.tadedon</groupId>
  <artifactId>tadedon-gwt-dev</artifactId>
  <version>1.0-SNAPSHOT</version>
  <scope>provided</scope>
</dependency>

And add -server com.xemantic.tadedon.gwt.dev.JettyLauncher to your google web application launcher. This is maven friendly jetty launcher which might be necessary in some situations.

I hope it will help you. Are you interested in communication between gwt and richfacaes application?

OTHER TIPS

If you want, take a look at <SEAM_HOME>/examples/remoting/gwt. From there, run (Make sure you have installed ANT before using it)

ant

Here goes its readme.txt file

You can view the example at: http://localhost:8080/seam-helloworld/org.jboss.seam.example.remoting.gwt.HelloWorld/HelloWorld.html

GWT: If you want to rebuild the GWT front end, you will need to download GWT, and configure build.properties to point to it. You can then run "ant gwt-compile" from this directory. It is pre-built by default. If you want to use the GWT hosted mode, well, read all about it from the GWT docs !

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top