Calling Java Methods in MXML Application

Avatar

Avatar

Madhu_123

Avatar

Madhu_123

Madhu_123

10-07-2008

Hai ,



I am new to flex . I want to call a Java Method in my MXML
Application . Can anyone give a Simple example for this One .



Thanks

Madhu

Replies

Avatar

Avatar

JCRobinson

Avatar

JCRobinson

JCRobinson

10-07-2008

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml">



<mx:RemoteObject id="myRemoteObject"
destination="myObject"/>



<mx:Button label="Get String"
click="myRemoteObject.sayHello()"/>

<mx:Label
text="{myRemoteObject.sayHello.lastResult}"/>



</mx:Application>



Thats a abasic way.... Im new to Java, how do you communicate
the blazeDS, such as MessageService.getSubscriberIds ?

Avatar

Avatar

Madhu_123

Avatar

Madhu_123

Madhu_123

11-07-2008

Thanks. But When i run this Application it throws an Action
Script Error Like this .

[RPC Fault faultString="[MessagingError message='Destination
'myObject' either does not exist or the destination has no channels
defined (and the application does not define any default
channels.)']" faultCode="InvokeFailed" faultDetail="Couldn't
establish a connection to 'myObject'"]

at mx.rpc::AbstractInvoker/
http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc...

at mx.rpc.remoting.mxml::Operation/
http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc...

at
mx.rpc.remoting::Operation/send()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\remoting\Operation.as:113]

at Function/
http://adobe.com/AS3/2006/builtin::apply()

at
mx.rpc.remoting.mxml::Operation/send()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\remoting\mxml\Operation.as:170]

at Function/
http://adobe.com/AS3/2006/builtin::apply()

at mx.rpc::AbstractService/
http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()[E:\dev\3.0.x\frameworks\projects\...

at s2/___s2_Button1_click()[C:\Workshop for eclipse\work
space\Flex\DCSearch\flex_src\s2.mxml:6]



Can u help me



Madhu

Avatar

Avatar

JCRobinson

Avatar

JCRobinson

JCRobinson

11-07-2008

First off..



The code won’t run without a java package and class (I
use the java tools for eclips) that needs to be exposed via the
reomote-config.xml (under blazeDS)



After that you need to call it via the remoteObject (In
flex).



Do you need some pointers to tutorials that explain this?



To get a good understanding of how Flex, blazeDS and Java
communicate. Tyr this forum:
http://www.flexlive.net/?cat=6



It’s where I started from last week. Also Google the
things you are not sure about, it’s surprising what you will
find.



Also again lol, Flex Data Services (LiveCycle) and BlazeDS
are very similar dependent on the base capabilities. At the moment
you may find more documentation for Flex Data Service and LiveCycle
than blazeDS.



Most of the information I have found applies to all
three!!!!!