前提条件
・Eclips3.1
・Jdk1.5
・Flex2
・tomcat5.5
・Dolteng
1.http://s2flex2.sandbox.seasar.org/ja/#download より「S2Flex2」、「S2Flex2 Example」をダウンロードする。
1.[ファイル] → [新規] → [プロジェクト] → [Chura Project]
2.「プロジェクト名」、ルートパッケージ、プロジェクトタイプ「Teeda + S2Dao」を設定後、終了
3.S2Flex2の「s2-flex2-X.X.X.jar」、S2Flex2 Exampleの「s2-flex2-tiger-X.X.X.jar」を「プロジェクトルート\src\main\webapp\WEB-INF\lib」にコピーし、
ビルドパスを設定する。
4.「プロジェクトルート\src\lib\wc」フォルダーを作成しS2Flex2 Exampleの「s2flex2-components.swc」をコピー後
ビルドパスを設定する。
5.Flex出力パスをsrc\main\webapp\binに設定
6.[プロジェクトを右クリック]→プロパティー→Tomcatを選択後、「コンテキスト名」、「Webアプリケーション・ルートとするサブディレクトリ
(オプション)」にを設定後、適用
7.プロジェクトの右クリックで[Flexプロジェクトの特性] → [Flexプロジェクトの特性を追加]
8.buildエラーとなるのでメッセージの上で右クリック[HTMLテンプレートの再作成]をクリック
9.プロジェクトルート\src\main\resource内にS2Flex2/esourcesの以下を追加
・amf3.dicon
・remoting_amf3.dicon
10.プロジェクトルート\src\main\resource\app.diconに以下を追加
<include path="remoting_amf3.dicon"/>
11.s2container.diconを以下に書き換える
<include condition="#ENV == 'ut'" path="warmdeploy.dicon"/>
<include condition="#ENV == 'ct'" path="hotdeploy.dicon"/>
<include condition="#ENV != 'ut' and #ENV != 'ct'" path="cooldeploy.dicon"/>
12.web.xmlの設定
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<filter>
<filter-name>s2filter</filter-name>
<filter-class>org.seasar.framework.container.filter.S2ContainerFilter</filter-class>
</filter>
<filter>
<filter-name>hotdeployfilter</filter-name>
<filter-class>org.seasar.framework.container.hotdeploy.HotdeployFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>s2filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>hotdeployfilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.seasar.teeda.core.webapp.TeedaConfigureListener</listener-class>
</listener>
<servlet>
<servlet-name>s2servlet</servlet-name>
<servlet-class>org.seasar.framework.container.servlet.S2ContainerServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>gateway</servlet-name>
<servlet-class>org.seasar.flex2.rpc.remoting.RemotingGateway</servlet-class>
<init-param>
<param-name>showGetResponse</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>useSession</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>s2servlet</servlet-name>
<url-pattern>/s2servlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>gateway</servlet-name>
<url-pattern>/bin/gateway</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>gateway</servlet-name>
<url-pattern>/gateway</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
13.サンプルアプリの作成
--MXML--
作成されたmxml(この場合Sample.mxml)を使用しサンプルの作成する
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:s2="http://www.seasar.org/s2flex2/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
private function onSendClick(e:Event) : void{
amf.execute("Flex Send!");
}
public function onResult(ret:ResultEvent):void
{
this.resultText.text = ret.result as String;
}
public function onFault(ret:FaultEvent):void
{
this.resultText.text = "通信失敗!!!";
}
]]>
</mx:Script>
<s2:S2Flex2Service id="amf" destination="tester01Service"
result="onResult(event)" fault="onFault(event)" showBusyCursor="true" />
<mx:VBox width="100%" height="100%" horizontalAlign="center">
<mx:Label text="S2Flex2通信サンプル" fontSize="20"/>
<mx:Button id="send" label="通信" click="onSendClick(event)"/>
<mx:Text id="resultText"/>
</mx:VBox>
</mx:Application>
-java-
-----Tester01Service-----
package sample.service;
public interface Tester01Service {
public abstract String execute(Object obj);
}
-----Tester01ServiceImpl-----
package sample.service.impl;
import org.seasar.flex2.rpc.remoting.service.annotation.RemotingService;
import sample.service.Tester01Service;
@RemotingService
public class Tester01ServiceImpl implements Tester01Service{
public String execute(Object obj){
System.out.println(obj.toString());
return "Flex Connect OK !!";
}
}
------------------------------
14.稼動確認
tomcatを起動し以下を実行
http://localhost:8080/Sample/bin/Sample.html