熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

Java+Flex整合應用簡單示例

2022-06-13   來源: Java核心技術 

  java

  Java代碼

  package com;

  public class LoginDemo {

  public String validate(String usernameString password){

  String message =login failed!;

  if(usernameequals(lin)&&passwordequals(lin)){

  message = login successed!;

  }

  return message;

  }

  }

  remotingconfigxml

  Java代碼

  <?xml version= encoding=UTF?>

  <service id=remotingservice

  class=ssagingservicesRemotingService>

  <adapters>

  <adapterdefinition id=javaobject class=ssagingservicesremotingadaptersJavaAdapter default=true/>

  </adapters>

  <defaultchannels>

  <channel ref=myamf/>

  </defaultchannels>

  <destination id=login>

  <properties>

  <source>comLoginDemo</source>

  </properties>

  </destination>

  </service>

  mxml

  Java代碼

  <?xml version= encoding=utf?>

  <mx:Application xmlns:mx= layout=absolute>

  <mx:Script>

  <![CDATA[

  import mxrpceventsFaultEvent;

  import mxrpceventsResultEvent;

  import ntrolsAlert;

  [Bindable]

  var returnValue:String;

  var username:String;

  var password:String;

  function sendRequest():void{

  username=usernametext;

  password=passwordtext;

  rovalidate(usernamepassword);

  roaddEventListener(ResultEventRESULTresults);

  }

  function results(event:ResultEvent):void{

  returnValue=eventresult as String;

  }

  function faultHandler(event:FaultEvent):void{

  Alertshow(eventfaulttoString());

  }

  ]]>

  </mx:Script>

  <mx:RemoteObject id=ro destination=login fault=faultHandler(event)>

  </mx:RemoteObject>

  <mx:Panel height= width= layout=absolute title=用戶登錄>

  <mx:Label x= y= text=用戶名 width=></mx:Label>

  <mx:Label x= y= text=密碼 width=></mx:Label>

  <mx:TextInput id=username x= y=/>

  <mx:TextInput id=password x= y=/>

  <mx:Button x= y= label=登錄 click=sendRequest()/>

  <mx:Label x= y= text={returnValue}/>

  </mx:Panel>

  </mx:Application>


From:http://tw.wingwit.com/Article/program/Java/hx/201311/26973.html
  • 上一篇文章:

  • 下一篇文章:
  • 推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.