【问题标题】:SEAM GWT IntegrationSEAM GWT 集成
【发布时间】:2010-09-08 09:43:03
【问题描述】:

我正在尝试将 GWT 与 SEAM 集成。我跟着Docs 并试图运行

示例如下。

  1. 我创建了一个 GWT 项目,使用 Eclipse Galileo 并创建了示例中给出的类

  2. 然后我将 Seam 2.0.2 jar 添加到构建路径

  3. 我使用 Google GWT 编译器和 eclipse UI 编译了应用程序。

  4. 最后我运行了应用程序。

首先我想知道以上步骤是否正确。运行应用程序后,我没有得到想要的结果。

这也是将 GWT 与 Seam 集成的唯一方法吗?

更新

我已经使用 ant 运行了这个示例。但我练习的目的是通过 eclipse ui 运行它。

我创建了自己的名为 GWTTest 的项目,并尝试在 Eclipse 中重新创建示例

用户界面。我注意到了一些事情。 GWT Compile via Eclipse UI 在war 文件中创建一个名为gwttest 的目录。因为ant创建的目录结构不同。

在示例中AskQuestionWidget getService函数中有一段代码如下

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

如何修改此代码以适应我的目录结构?

【问题讨论】:

    标签: gwt integration seam seam2


    【解决方案1】:

    我们使用 seam+richfaces+gwt,效果很好。尽管我们使用 maven 构建一切,但我想您也可以使用 ant。总体思路是在 GWT 开发模式下启动整个 Web 应用程序。您不必编译所有内容(在 GWT 编译器的情况下需要很长时间)。开发模式将按需编译请求的资源。通过这种方式运行 GWT 应用程序,您还可以调试客户端代码。

    也可以调用 GWT 方法来响应接缝动作。

    更新:

    我可以详细说明一下我们的解决方案:

    Maven

    您的项目应配置为packaging: war。有一些关于使用 maven(也是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

    对于 GWT,将以下部分添加到您的 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>
    

    这个配置应该在编译 - seam 和 gwt 时产生战争。如果你想在开发模式下使用这样的项目,也可以在pom.xml

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

    并将-server com.xemantic.tadedon.gwt.dev.JettyLauncher 添加到您的谷歌网络应用程序启动器。这是 maven 友好的码头发射器,在某些情况下可能是必要的。

    希望对你有所帮助。您对 gwt 和richfacaes 应用程序之间的通信感兴趣吗?

    【讨论】:

    • 你能给我提供更多关于如何解决这个问题的想法
    • 非常感谢您的详细更新,但不幸的是,我对 maven 或 ant 都不是很熟悉。所以必须阅读它们。还是谢谢
    【解决方案2】:

    如果需要,请查看 /examples/remoting/gwt。从那里运行(确保在使用前已安装 ANT)

    ant
    

    这里是它的 readme.txt 文件

    您可以在以下位置查看示例: http://localhost:8080/seam-helloworld/org.jboss.seam.example.remoting.gwt.HelloWorld/HelloWorld.html

    GWT:如果你想重建 GWT 前端,你需要下载 GWT,并配置 build.properties 指向它。然后,您可以从此目录运行“ant gwt-compile”。它是默认预构建的。 如果您想使用 GWT 托管模式,请阅读 GWT 文档中的所有相关信息!

    【讨论】:

    • 您好,我使用了 ant 并构建了上面的示例。自述文件似乎已过时。我正在使用 seam 2.0.2、gwt 2.0.4,访问此示例的正确 url 是:localhost:8080/seam-gwt/HelloWorld.html
    猜你喜欢
    • 2012-01-04
    • 1970-01-01
    • 2012-08-27
    • 2013-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-23
    • 2017-10-08
    相关资源
    最近更新 更多