SEAM GWT 集成

发布于 2024-09-18 09:03:51 字数 826 浏览 14 评论 0原文

我正在尝试将 GWT 与 SEAM 集成。我遵循 文档 并尝试运行该

示例如下。

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

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

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

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

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

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

更新

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

我创建了自己的名为 GWTTest 的项目,并尝试在 Eclipse

UI 中重新创建该示例。我注意到了一些事情。通过 Eclipse UI 进行 GWT 编译会在 war 文件内创建一个名为 gwttest 的目录。 ant 创建的目录结构不同。

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

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

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

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云淡风轻 2024-09-25 09:03:51

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

还可以调用 GWT 方法来响应接缝操作。

更新:

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

Maven

您的项目应该使用packaging: war进行配置。有一些关于使用maven(还有richfaces)设置seam的官方说明:

http://docs.jboss.org/seam/2.2.1.CR2/reference/en-US/html/dependency.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 添加到您的 google网络应用程序启动器。这是 Maven 友好的码头启动器,在某些情况下可能是必要的。

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

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?

我纯我任性 2024-09-25 09:03:51

如果需要,请查看 /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 文档中的所有相关内容!

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 !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文