티스토리 뷰

참조 : http://blog.naver.com/rlaaudtnr8/50053091083

==============================
   톰켓 설정
==============================

1. 일단 톰켓에 context 를 하나 추가한다.
톰켓의 server.xml 에 아래와 같이 추가하고 ROOT 폴더를 복사하여 폴더명을 WidgetDemo 와 같이 변경 
< Context docBase="D:projectWidgetDemo" path="/WidgetDemo" reloadable="true" />
자세한 방법은 아래를 참조
=>
잘 뜨는지 테스트 하고 .. http://localhost:9090/WidgetDemo/

2. 연결 테스트를 확인하기 위한 자바파일을 생성해 보자. 이클립스를 이용해도 좋고..
난 그냥 손으로 직접 파일하나를 만들었다. ㅋㅋ;;

소스 : D:projectWidgetDemoWEB-INFsrcHelloWorld.java
클래스 : D:projectWidgetDemoWEB-INFclassesHelloWorld.class


public class HelloWorld {
   public String my_func() {
      return "Hello World!!";
   }
}



==============================
   LCDS 설정
==============================

3. lcds 가 설치되어 있다면 설정된 폴더로 이동하여 보자


flex.war 폴더를 압축을 해제하여 아래그림의 파일을 복사하여 D:projectWidgetDemo 아래에 복사하여 붙여넣는다.


뭐..사실 그냥 톰켓 webapps 아래 넣고 톰켓실행시키면 자동으로 잡을 수 있지만 컨텍스트를 따로 빼기위해 위와같은 작업을..ㅋㅋ

4. 복사했으면 이제 설정을 좀 수정해야 한다.
먼저, D:projectWidgetDemoWEB-INFflexservices-config.xml


< channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
   <endpoint url="http://localhost:9090/WidgetDemo/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
   <properties>
      <polling-enabled>false</polling-enabled>
   </properties>
< /channel-definition>



channel-definition 을 새로 추가해도 상관없지만 기존에 있는 my-amf 의 정보를 그대로 이용하겠다. 이것을 나의 설정에 맞게 endpoint 의 url 정보만 수정했다.
=> http://localhost:9090/WidgetDemo

그리고, D:projectWidgetDemoWEB-INFflex
emoting-config.xml 파일의 수정


<destination id="HelloRO" adapter="java-object">
   <properties>
      <|source>HelloWold</|source>
   </properties>
< /destination>


>  <|source>HelloWorld</|source>
여기서 HelloWorld 는 자바소스의 클래스명과 일치!!
>  id="HelloRO"
HelloRO 는 Flex 에서 연계시 사용하게 된다.
>  만약 services-config.xml 에서 채널을 추가하여 사용할 경우 아래와 같이 remotin-config.xml 파일에 채널명을 추가해주고 할당해 주어야 하지만 여기서는 디폴트 my-amf 를 사용하였으므로 불필요하다.


< default-channels>
   <channel ref="added-amf" />
< /default-channels>
< destination id="AddedRO">
   <properties>
      <|source>AddedHelloWorld</|source>
   </properties>
   <channels>
      <channel ref="added-amf" />
   </channels>
< /destination>



==============================
   Flex Builder 3 설정
==============================

5. 이제 Flex Builder 3 를 실행하여 프로젝트를 생성하자
아래와 같이 설정하면 생성한 프로젝트 WidgetDemo 안에 Flex 프로젝트를 생성하게 된다.
중요한 것은 Application server type 을 J2EE 로 하는 것이다.


Root folder, Root URL, Context root 를 설정하고 Validate Configuration 을 꼭 하도록 하자.




Finish 하고나면 아래와 같이 프로젝트가 생성된것을 볼수 있다.


6. 아.. 오타가;; 어쨌든;;
WidegetDemo.mxml 을 아래와 같이 수정하자.


< ?xml version="1.0" encoding="utf-8"?>
< mx:Application xmIns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
< mx:Script>
   <![CDATA[
      import mx.rpc.events.FaultEvent;
      import mx.rpc.events.ResultEvent;

      private function resultHandler(event:ResultEvent):void {
         txtResult.text = event.result.toString();
      }
      
      private function faultHandler(event:FaultEvent):void {
         txtResult.text = event.toString();
      }
   ]]>
< /mx:Script>
< mx:RemoteObject id="test" destination="HelloRO" showBusyCursor="true" result="resultHandler(event)" fault="faultHandler(event)">
< /mx:RemoteObject>
< mx:Button x="19" y="10" label="RemoteObject 호출" click="test.my_func()" />
< mx:TextArea id="txtResult" x="10" y="40" width="229" height="218" />
< /mx:Application>



7. 끝이다. WidgetDeom 를 실행하면 연계가 올바른지 테스트만 하면된다.
http://localhost:9090/WidegetDemo/FlexProject/bin-debug/WidegetDemo.html
올바른 테스트 결과


참고한 싸이트
http://blog.naver.com/0186042076/60048920385
http://siking.tistory.com/139

'Language > Flex' 카테고리의 다른 글

[ Flex ] PHP 연동 예제 - 오라클 연동 추가  (0) 2015.11.29
[ Flex ] SQLite 기초 강좌  (0) 2015.11.29
[ Flex ] ArrayCollection 데이터 추가  (0) 2015.11.29
[ Flex ][ UIComponent ] ComboBox  (0) 2015.11.29
[ Flex ] DataGrid  (0) 2015.11.29
Total
Today
Yesterday
최근에 올라온 글
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31