1、web.xml中配置lcds
2、/WEB-INF/flex/services-config.xml
3、login.mxml
3、Java类,DataSource.java
<?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>
<display-name>flcds</display-name>
<description>my flcds</description>
<!-- Http Flex Session attribute and binding listener support -->
<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>
<!-- MessageBroker Servlet -->
<servlet>
<servlet-name>MessageBrokerServlet</servlet-name>
<display-name>MessageBrokerServlet</display-name>
<servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
<init-param>
<param-name>services.configuration.file</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
</web-app>2、/WEB-INF/flex/services-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<service id="remoting-service" class="flex.messaging.services.RemotingService">
<adapters>
<adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
</adapters>
<default-channels>
<channel ref="my-amf"/>
</default-channels>
<!--my business class-->
<destination id="DataSource">
<properties>
<source>com.dream.main.DataSource</source>
<scope>application</scope>
</properties>
</destination>
</service>
</services>
<channels>
<!-- Servlet Based endpoints -->
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel-definition>
</channels>
<logging>
<target class="flex.messaging.log.ConsoleTarget" level="Debug">
<properties>
<prefix>[LCDS] </prefix>
<includeDate>false</includeDate>
<includeTime>false</includeTime>
<includeLevel>false</includeLevel>
<includeCategory>false</includeCategory>
</properties>
<filters>
<pattern>*</pattern>
</filters>
</target>
</logging>
<system>
<redeploy>
<enabled>true</enabled>
<watch-interval>20</watch-interval>
<watch-file>{context.root}/WEB-INF/flex/services-config.xml</watch-file>
<touch-file>{context.root}/WEB-INF/web.xml</touch-file>
</redeploy>
</system>
</services-config>3、login.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
private function startLogin(str:String):void{
dataSource.login(str);
dataSource.addEventListener(ResultEvent.RESULT,handlerLogin);
}
private function handlerLogin(e:ResultEvent) :void {
Alert.show(e.result.toString(),"提示");
}
]]>
</mx:Script>
<mx:RemoteObject id="dataSource" destination="DataSource"/>
<mx:Button click="startLogin('忧里修斯')" label="登陆" x="252.5" y="190" width="132" height="32"/>
</mx:Application>3、Java类,DataSource.java
package com.dream.main;
public class DataSource {
public String login(String username){
return username+":恭喜你,登陆成功!";
}
}
本文介绍了如何在web.xml中配置LCDS (LiveCycle Data Services) 的基本设置,并展示了如何通过services-config.xml文件定义服务及通道。此外,还提供了一个使用MXML编写的简单登录界面示例,该示例利用了RemoteObject组件与后端进行交互。
172

被折叠的 条评论
为什么被折叠?



