سؤال

أحاول دمج GWT مع التماس. لقد تابعت مستندات وحاول تشغيل

مثال على النحو التالي.

  1. لقد قمت بإنشاء مشروع GWT ، باستخدام Eclipse Galileo وأنشأت الفصول على النحو الوارد في المثال

  2. ثم أضفت Seam 2.0.2 الجرار إلى مسار البناء

  3. قمت بتجميع التطبيق ، باستخدام برنامج التحويل البرمجي لـ Google GWT باستخدام Eclipse UI.

  4. وأخيرا ركضت التطبيق.

أولا أود أن أعرف ما إذا كانت الخطوات المذكورة أعلاه صحيحة. بعد تشغيل التطبيق ، لا أحصل على النتيجة المرجوة.

هل هذه هي الطريقة الوحيدة لدمج GWT مع التماس؟

تحديث

لقد حصلت على هذا المثال يعمل باستخدام ANT. لكن الهدف من تمرينتي هو تشغيله عبر Eclipse UI.

لقد قمت بإنشاء مشروعي الخاص بالاسم GWTTEST وحاولت إعادة إنشاء المثال في الكسوف

واجهة المستخدم. هناك بعض الأشياء التي لاحظتها. GWT Compile عبر Eclipse UI ينشئ دليلًا بالاسم GWTTest داخل ملف الحرب. حيث يختلف بنية الدليل التي أنشأتها ANT.

في المثال ، هناك جزء من التعليمات البرمجية في وظائف GetService AskQuestionWidget على النحو التالي

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

كيف يمكنني تعديل هذا الرمز لتناسب بنية الدليل الخاصة بي؟

هل كانت مفيدة؟

المحلول

نستخدم Seam+Richfaces+GWT وهو يعمل بشكل جيد للغاية. على الرغم من أننا نبني كل شيء مع Maven ، إلا أنني أفترض أنه يمكنك استخدام ANT أيضًا. الفكرة العامة هي بدء تطبيق الويب بأكمله في وضع تطوير GWT. ليس عليك تجميع كل شيء (والذي يستغرق وقتًا طويلاً في حالة برنامج التحويل البرمجي GWT). سيقوم وضع التطوير بتجميع الموارد المطلوبة عند الطلب. من خلال تشغيل تطبيق GWT بهذه الطريقة ، يمكنك أيضًا تصحيح الرمز الجانبي للعميل.

من الممكن أيضًا استدعاء أساليب GWT استجابةً لإجراءات التماس.

تحديث:

يمكنني توضيح حلنا قليلاً:

مافن

يجب تكوين مشروعك مع 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_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 Web الخاصة بك. هذا هو Maven Friendly Jetty Launcher والذي قد يكون ضروريًا في بعض الحالات.

آمل أن تساعدك. هل أنت مهتم بالاتصال بين تطبيق GWT و Richfacaes؟

نصائح أخرى

إذا كنت تريد ، ألق نظرة على u003CSEAM_HOME>/أمثلة/عن بعد/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!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top