Hi,
I have created a very simple 2 state mxml file(attached
below) where you submit a name which is passed to a RemoteObject
which appends "Welcome " to the input string & returns the
whole string back.
The java class which does this is,
package samples.SimpleRemoteObject;
public class Echo {
public Echo(){
}
public String getString(String str){
return "Welcome " + str ;
}
}
I have added the following to flex-remoting-service.xml under
c:\tomcat\webapps\flex\WEB-INF\flex,
<destination id="EchoString">
<properties>
<source>samples.SimpleRemoteObject.Echo</source>
</properties>
</destination>
The <default-channels> & <adapters>
definition was already there.
I also put Echo.class under
C:\tomcat\webapps\flex\WEB-INF\classes\samples\SimpleRemoteObject.
After Tomcat(v5.5.9) is started, it correctly loads the
initial page
at
http://localhost:8080/flex/SimpleRemoteObject/SimpleRemoteObject.htmlbut after I click on submit, I always get "Error: Unknown
destination 'EchoString'". I have tried renaming the destination
names but there is no change in behavior.
Please let me know what am I doing wrong. All the samples are
running fine
though. This is my first attempt on doing something with
Flex.
Thanks,
Aejaz
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"xmlns="*" layout="absolute">
<mx:Script>
<![CDATA[
import mx.rpc.events.*;
import mx.collections.*;
import mx.controls.*
private function getNameHandler(event:ResultEvent):void
{
Result.text = event.result.toString();
currentState='TargetState';
}
private function faultHandler(event:FaultEvent):void
{
Alert.show(event.fault.faultstring, "Error");
}
]]>
</mx:Script>
<mx:states>
<mx:State name="TargetState">
<mx:RemoveChild child="{button1}"/>
<mx:RemoveChild child="{formInput}"/>
<mx:RemoveChild child="{label1}"/>
<mx:AddChild position="lastChild">
<mx:Label x="99" y="130" width="265" height="28"
id="Result"/>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:RemoteObject id="SendStringBack"
destination="EchoString" showBusyCursor="true"
fault="faultHandler(event)">
<mx:method name="getString"
result="getNameHandler(event)">
<mx:arguments>
<str>
{formInput.text}
</str>
</mx:arguments>
</mx:method>
</mx:RemoteObject>
<mx:TextInput x="119" y="129" id="formInput"/>
<mx:Button x="119" y="170" label="Submit" fontSize="13"
id="button1" click="SendStringBack.getString.send()"/>
<mx:Label x="119" y="86" text="What is your name ?"
width="160" fontSize="15" id="label1"/>
</mx:Application>
Text