Spring. net + FluorineFx 프로젝트 구축 의 3, Flex 인터페이스 코드 작성
3.1 기본 Sample 클래스 의 내용 작성
"FluorineFx ServiceLibrary" 라 이브 러 리 를 만 들 때 기본적으로 Sample 클래스 를 생 성 합 니 다. 이 클래스 에 방법 을 추가 하면 Flex 단 을 호출 할 수 있 습 니 다.
3.1.1 우선 서비스 대상 획득
Sample 의 구조 방법 에서 대상 의 인용 을 가 져 옵 니 다.
public Sample()
{
IApplicationContext context = WebApplicationContext.GetRootContext();
this.userService = context.GetObject("userService") as IUserService;
}
3.1.2 서비스 호출 방법 으로 기능 실현
public Boolean Logon(string userName, string password)
{
return userService.Logon(userName, password);
}
3.2 사용자 정의 Flex 단 원 격 호출 클래스
기본적으로 이것 은 자동 으로 생 성 되 는 Sample 클래스 이 며 사용자 정의 도 가능 합 니 다. 이렇게 하면 Spring 프레임 워 크 를 사용 하여 XML 에서 필요 한 서비스 대상 을 초기 화 할 수 있 습 니 다.
먼저, 세 가지 유형 을 정의 하고 ① 프론트 플 렉 스에 인 터 페 이 스 를 놓 는 플 렉 스 서비스;② IFlexFactory 인 터 페 이 스 를 계승 하 는 클래스 SpringFlexFactory;③ Factory Instance 류 의 SpringFactory Instance 를 계승 한다.
3.2.1 FlexService 클래스 쓰기:
using System;
using System.Collections.Generic;
using System.Text;
using FluorineFx;
using Li.Interfaces;
namespace Li.FlexService
{
[RemotingService]
public class FlexService
{
private IUserService UserService;
public FlexService(IUserService UserService)
{
this.UserService = UserService;
}
/// <summary>
///
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <returns></returns>
public Boolean Logon(string userName, string password)
{
return this.UserService.Logon(userName, password);
}
}
}
3.2.2 SpringFlexFactory 클래스 쓰기:
using System;
using System.Collections.Generic;
using System.Text;
using FluorineFx.Messaging;
namespace Li.FlexService
{
class SpringFlexFactory : IFlexFactory
{
#region IFlexFactory
public FactoryInstance CreateFactoryInstance(string id, System.Collections.Hashtable properties)
{
return new SpringFactoryInstance(this, id, properties);
}
public object Lookup(FactoryInstance factoryInstance)
{
return (factoryInstance as SpringFactoryInstance).Lookup();
}
#endregion
}
}
3.2.3 SpringFactory Instance 류 의 작성 방법:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using FluorineFx.Messaging;
using System.Collections;
using Spring.Context;
using Spring.Context.Support;
namespace Li.FlexService
{
class SpringFactoryInstance : FactoryInstance
{
public SpringFactoryInstance(IFlexFactory factory, string id, Hashtable properties)
: base(factory, id, properties)
{
}
public override object Lookup()
{
IApplicationContext context = WebApplicationContext.GetRootContext();
return context.GetObject(context.GetObjectNamesForType(typeof(FlexService)).FirstOrDefault());
}
}
}
3.3.4 세 개의 프로필 을 변경 해 야 합 니 다.
① "FluorineFx ASP. NET Web Site" 사이트 의 "WEB - INF \ flex \ \ services - config. xml" 설정 파일 에 루트 services - config 를 추가 합 니 다.
<factories>
<factory id="springFlexFactory" class="Li.FlexService.SpringFlexFactory" />
</factories>
② "FluorineFx ASP. NET Web Site" 사이트 아래 "WEB - INF \ flex \ \ remoting - config. xml" 설정 파일 에 destination 아래 properties 에 탭 < factory > springFlexFactory < / factory > 를 추가 합 니 다.
<destination id="fluorine">
<properties>
<factory>springFlexFactory</factory>
<source>*</source>
</properties> ...
</desination>
③ 웹. config 설정 파일 에 FlexService 클래스 를 예화 하고 spring 의 objects 에 object 탭 을 추가 합 니 다.
<object type="Li.FlexService.FlexService, Li.FluorineFx">
<constructor-arg ref="userService" />
</object>
3.3 Flex 단 호출 C \ # 인터페이스
1. 먼저 'FluorineFx ASP. NET Web Site' 사이트 의 경우 IIS 에 설정 합 니 다.IIS 에 가상 디 렉 터 리 를 새로 만 듭 니 다.2. Flex 단 에서 RemoteObject 탭 을 사용 하여 배경 호출 을 하고 3. RemoteObject 탭 의 속성 설정 은 다음 과 같 습 니 다.
① destination 내용 은 "FluorineFx ASP. NET Web Site" 사이트 의 "WEB - INF \ \ flex \ reoting - config. xml" 설정 파일 에서 destination 태그 의 id 내용 입 니 다.② endpoint 내용 은 "FluorineFx ASP. NET Web Site" 사이트 아래 "Gateway. aspx" 페이지 의 IIS 주소 입 니 다.③ Source 의 내용 은: "FluorineFx ServiceLibrary" 라 이브 러 리 에서 Flex 인터페이스 코드 를 작성 하 는 클래스 의 패키지 경로 (기본 값 은 Sample 클래스, 사용자 정의 시 상황 에 따라) 입 니 다.
3. RemoteObject 탭 에 추가 할 내용:
① fault 이벤트: 배경 을 호출 하 는 데 실 패 했 을 때 발생 하 는 사건 을 호출 하 는 데 실 패 했 습 니 다.② showBusyCursor = "true": 백 엔 드 가 되 돌아 오지 않 을 때 마 우 스 를 불 러 옵 니 다 (시계 가 애니메이션 을 돌 립 니 다).③ method 태그: name 은 배경 을 호출 할 방법 이름 이 고 result 는 이 방법 을 호출 한 후에 자극 하 는 이벤트 입 니 다.
4. 호출 이 필요 할 때: remoteObject. UserLogin (매개 변수 1, 매개 변수 2) 을 호출 합 니 다.
<mx:RemoteObject id="remoteObject" destination="fluorine" endpoint="http://192.1.1.113/liWebService/Gateway.aspx"
source=" Li.FlexService.FlexService" fault="remoteFaultHandler(event)" showBusyCursor="true">
<mx:method name="UserLogin" result="UserLoginResultHandler(event)" />
</mx:RemoteObject>
로그 인 기능 간단 한 코드:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" minWidth="1003" minHeight="600" fontSize="12">
<mx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
/**
* ,
*/
private function buttonLogon_clickHandler(event:MouseEvent):void
{
this.generalRemoteObject.Logon( this.textInputUserName.text, this.textInputPassword.text );
}
private function logonResultHandler( event:ResultEvent ):void
{
if( event.result )
{
Alert.show(" ");
}
else
{
Alert.show(" , ");
}
}
public function remoteFaultHandler( event:FaultEvent ):void
{
Alert.show("remote ");
}
]]>
</mx:Script>
<mx:RemoteObject id="generalRemoteObject" destination="fluorine" showBusyCursor="true"
endpoint="http://192.1.1.113/liWebService/Gateway.aspx"
source="Li.FlexService.FlexService" >
<mx:method name="Logon" result="logonResultHandler(event)"/>
</mx:RemoteObject>
<mx:HBox horizontalCenter="0" verticalCenter="90" width="400" verticalAlign="middle">
<mx:Form >
<mx:FormItem label=" :">
<mx:TextInput id="textInputUserName" width="150" />
</mx:FormItem>
<mx:FormItem label=" :">
<mx:TextInput id="textInputPassword" width="150" displayAsPassword="true" />
</mx:FormItem>
</mx:Form>
<mx:Button label=" " click="buttonLogon_clickHandler(event)" />
</mx:HBox>
</mx:Application>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
thymeleaf로 HTML 페이지를 동적으로 만듭니다 (spring + gradle)지난번에는 에서 화면에 HTML을 표시했습니다. 이번에는 화면을 동적으로 움직여보고 싶기 때문에 입력한 문자를 화면에 표시시키고 싶습니다. 초보자의 비망록이므로 이상한 점 등 있으면 지적 받을 수 있으면 기쁩니다! ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.