- 浏览: 236141 次
- 性别:
- 来自: 北京
最新评论
-
LoveJavaMM:
[color=red][/color]为什么我的自定义组建不出 ...
跟我StepByStep学FLEX教程------Demo6之自定义事件&自定义组件 -
wangsiaofish:
auditionlsl 写道在使用Flex4时:
代码:cre ...
跟我StepByStep学FLEX教程------Demo5之事件Event -
wangsiaofish:
成功,perfect.
跟我StepByStep学FLEX教程------Demo7之页面跳转 -
happyzjj:
感谢楼主的共享,很受用
跟我StepByStep学FLEX教程------结束语 -
娇雨zj:
请问:我用第二种绑定了数据,BindingUtils.bind ...
跟我StepByStep学FLEX教程------Demo4之进度条数据绑定
跟我StepByStep学FLEX教程------Demo11之HelloJavaFlex
说明:该文系作者原创,请勿商用或者用于论文发表,转载必须经作者同意并且注明出处。
这一讲接上一讲讲述,所以阅读本讲之前一定要看上一讲每一步。
新建一个Java类,切换到Java开发模式:
呵呵,是不是很方便,Java就Java,Flex就Flex,都在myeclipse中切换模式就完成了。
1、新建HelloJavaFlex.java,如下(目录在src下的com.test):
package com.test;
/**
* @author Wang YiSong
* @version $Revision: $, $Date: $
*/
public class HelloJavaFlex {
public String helloJavaFlex(String name) {
System.out.println("哈哈,JAVA和FLEX可以通信了!");
return "Hello,'" + name + "':JAVA和FLEX可以通信了";
}
}
2、在WebRoot目录下的WEB-INF目录下自动生成的remoting-config.xml中增加如下配置:
<destination id="helloJavaFlex">
<properties><source>com.test.HelloJavaFlex</source></properties>
</destination>
3、HelloFlexPro.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;
public function remotingHelloJavaFlex():void{
var logNam: String = namInputTxt.text;
remoteHello.helloJavaFlex(logNam);
remoteHello.addEventListener(ResultEvent.RESULT, getRoHelloRes);
}
private function getRoHelloRes(e: ResultEvent) :void {
Alert.show(e.result.toString());
}
]]>
</mx:Script>
<mx:RemoteObject destination="helloJavaFlex" id="remoteHello"></mx:RemoteObject>
<mx:Button label="JAVA+FLEX通信" click="remotingHelloJavaFlex();" x="121" y="96" fontSize="12" width="209"/>
<mx:Label text="姓名:" x="121" y="55" fontSize="12"/>
<mx:TextInput id="namInputTxt" x="170" y="55"/>
</mx:Application>
启动Tomcat,运行效果如下:
下一讲简单对该Demo进行解析。
评论
因为你.java文件,放的位置,程序没找到~~~~~~
还是因为你配置的原因吧。
你也可以,把类和.mxml文件放在一个src下,试试~~~
说错了,
.java文件,要放在src下边。不是跟.mxml文件一个得flex_src.
你检查下你的{context.root}吧。
因为你.java文件,放的位置,程序没找到~~~~~~
还是因为你配置的原因吧。
你也可以,把类和.mxml文件放在一个src下,试试~~~
在上一篇文章的评论中我说道
不知道是不是版本原因,无法从属性配置中做修改,导致出以下错误
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:290]
at mx.rpc::Responder/fault()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:58]
at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:103]
at mx.messaging::ChannelSet/faultPendingSends()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:1446]
at mx.messaging::ChannelSet/channelFaultHandler()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:1056]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.messaging::Channel/connectFailed()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\messaging\Channel.as:1069]
at mx.messaging.channels::PollingChannel/connectFailed()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\messaging\channels\PollingChannel.as:388]
at mx.messaging.channels::AMFChannel/statusHandler()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\messaging\channels\AMFC
以上错误中可以看到这样的路径http://localhost:8080/WebRoot/messagebroker/amf,这其中的WebRoot明显跟我们的项目名称不一致,最后发现把WebRoot/WEB-INF/flex/services-config.xml中的{context.root}全改成项目名字就可以了,如下:
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/HelloFlex/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
<channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
<endpoint url="https://{server.name}:{server.port}/HelloFlex/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
<properties>
<add-no-cache-headers>false</add-no-cache-headers>
</properties>
</channel-definition>
<channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/HelloFlex/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<polling-enabled>true</polling-enabled>
<polling-interval-seconds>4</polling-interval-seconds>
</properties>
</channel-definition>
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:290]
at mx.rpc::Responder/fault()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:58]
at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:103]
at mx.messaging::ChannelSet/faultPendingSends()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:1446]
at mx.messaging::ChannelSet/channelFaultHandler()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:1056]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.messaging::Channel/connectFailed()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\messaging\Channel.as:1069]
at mx.messaging.channels::PollingChannel/connectFailed()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\messaging\channels\PollingChannel.as:388]
at mx.messaging.channels::AMFChannel/statusHandler()[C:\autobuild\3.4.0\frameworks\projects\rpc\src\mx\messaging\channels\AMFChannel.as:411]
楼主,为什么我的remoting-config.xml是在WebRoot/WEB-INF/flex/remoting-config.xml下呢?
发表评论
-
跟我StepByStep学FLEX教程------读者答疑
2010-07-14 09:56 2371跟我StepByStep学FLEX教程------读者答疑 ... -
跟我StepByStep学FLEX教程------结束语
2009-09-15 11:56 2558跟我StepByStep学FLEX教程系列教程就暂 ... -
跟我StepByStep学FLEX教程------PDF版
2009-09-15 11:43 23050跟我StepByStep学FLEX教程------PDF版 ... -
跟我StepByStep学FLEX教程------贵在坚持
2009-09-15 10:53 2432跟我StepByStep学FLEX教程------贵在坚持 ... -
跟我StepByStep学FLEX教程------版权声明
2009-09-15 10:17 2339跟我StepByStep学FLEX教程------版权声明 ... -
跟我StepByStep学FLEX教程------Cairngorm之Command部分
2009-09-09 17:31 2413跟我StepByStep学FLEX教程------Cairng ... -
跟我StepByStep学FLEX教程------Cairngorm之核心控制流程
2009-09-09 16:40 2527跟我StepByStep学FLEX教程-- ... -
跟我StepByStep学FLEX教程------Cairngorm之Model Locator
2009-08-18 11:45 3154跟我StepByStep学FLEX教程-- ... -
跟我StepByStep学FLEX教程------Cairngorm之代码结构
2009-08-18 11:27 2568跟我StepByStep学FLEX教程------Cairng ... -
跟我StepByStep学FLEX教程------Demo15之Cairngorm
2009-08-10 15:45 2599跟我StepByStep学FLEX教程------Demo15 ... -
跟我StepByStep学FLEX教程------Cairngorm之环境准备
2009-08-06 15:01 4145跟我StepByStep学FLEX教程------Cairng ... -
跟我StepByStep学FLEX教程------Cairngorm之组成部分
2009-08-05 10:31 3035跟我StepByStep学FLEX教程------Cairng ... -
跟我StepByStep学FLEX教程------MVC
2009-07-28 10:41 2887跟我StepByStep学FLEX教程------MVC ... -
跟我StepByStep学FLEX教程------Caringorm之简介
2009-07-27 11:50 3371跟我StepByStep学FLEX教程------Caring ... -
跟我StepByStep学FLEX教程------Demo14Flex+Spring+Hibernate整合
2009-07-14 13:29 4769跟我StepByStep学FLEX教程------Demo14 ... -
跟我StepByStep学FLEX教程------Flex之Hibernate
2009-07-08 11:46 3245跟我StepByStep学FLEX教程------Flex之H ... -
跟我StepByStep学FLEX教程------Demo13之Flex访问数据库
2009-07-07 11:01 5229跟我StepByStep学FLEX教程-- ... -
跟我StepByStep学FLEX教程------访问数据库之hsqldb
2009-07-06 11:16 3587跟我StepByStep学FLEX教程------访问数据库之 ... -
跟我StepByStep学FLEX教程------访问数据库之JDBCTemplate
2009-07-03 11:06 3423跟我StepByStep学FLEX教程------访问数据库 ... -
跟我StepByStep学FLEX教程------Demo12之FLEX和Spring整合
2009-07-02 10:53 4735跟我StepByStep学FLEX教程------FLEX和S ...
相关推荐
1 24 跟我StepByStep学FLEX教程------Demo11之HelloJavaFlex 1 25 跟我StepByStep学FLEX教程------Java&Flex之RemoteObject 1 26 跟我StepByStep学FLEX教程------AMF 1 27 跟我StepByStep学FLEX教程------Demo12...
跟我StepByStep学FLEX教程------王一松.pdf
跟我StepByStep学FLEX教程------王一松
跟我StepByStep学FLEX教程 跟我StepByStep学FLEX教程 跟我StepByStep学FLEX教程 跟我StepByStep学FLEX教程 跟我StepByStep学FLEX教程
跟我StepByStep学FLEX教程.pdf 跟我StepByStep学FLEX教程.pdf 跟我StepByStep学FLEX教程.pdf 跟我StepByStep学FLEX教程.pdf 跟我StepByStep学FLEX教程.pdf
跟我StepByStep学FLEX教程 flex教程 flex大全
跟我StepByStep学FLEX教程------王一松
跟我StepByStep学FLEX,个人觉得比较好的一本关于flex书了,我最近也是刚开始学,网上没发现什么好资料,个人觉得这个不错,就传上来大家分享。设置资源分是迫不得已啊,喜欢在csdn上面下载东西,最近快没分了!
很详细的flex教程,适合新手入门很详细的flex教程,适合新手入门
安装算量(实例体验)入门教程(StepByStep)---消防水篇借鉴.pdf
安装算量(实例体验)入门教程(StepByStep)---消防报警篇分析.pdf
安装算量(实例体验)入门教程(StepByStep)---消防报警篇(2)借鉴.pdf
安装算量(实例体验)入门教程(StepByStep)---消防报警篇(2).pdf