How to connect Flex to Java class

4 views
Skip to first unread message

Gerald Anto

unread,
Nov 22, 2010, 12:42:52 AM11/22/10
to flex_delhi_india_group
Hello Friends,
How to connect Flex to Java class
i need to call a function in java class from Flex button.

Thanks & Regards,
A Gerald

AMIT PANDEY

unread,
Nov 22, 2010, 1:29:06 AM11/22/10
to flex_delhi_...@googlegroups.com
Hi Gerald,

It's not possible as you flex functions runs on Front end as Java Classes runs on Web/Application server, So if you need to make any such calls you need to call it using the remote calls in Flex. 

Regards
Amit Kr Pandey
+91-9873904496




--
You received this message because you are subscribed to the Google Groups "flex_delhi_india_group" group.
To post to this group, send email to flex_delhi_...@googlegroups.com.
To unsubscribe from this group, send email to flex_delhi_india_...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_delhi_india_group?hl=en.


Gerald Anto Fernando

unread,
Nov 22, 2010, 2:02:29 AM11/22/10
to flex_delhi_...@googlegroups.com
ok amit i will try for remote calls

Thanks&Regards,
Gerald A
--

AMIT PANDEY

unread,
Nov 22, 2010, 2:11:14 AM11/22/10
to flex_delhi_...@googlegroups.com
I believe you will get what ever  you want to achieve.

Good Luck..:)

Regards
Amit Kr Pandey
+91-9873904496



Gerald Anto Fernando

unread,
Nov 23, 2010, 2:58:53 AM11/23/10
to flex_delhi_...@googlegroups.com
hi Amit i am trying to open notepad from java.
i have done it in jsp with java i is working.
but when i call from flex to jsp notepad is not opened.
i used HttpService
give me some idea Amit.

Thanks&Regards,
Gerald A

AMIT PANDEY

unread,
Nov 23, 2010, 5:19:59 AM11/23/10
to flex_delhi_...@googlegroups.com
Hi Gerald,

If you open a notepad using your JSP, and call that JSP from your Flex application using httpservice then eventually it shud open the notepad on server machine as JSP will run on server machine and will open the applications on server machine. To interact with the system application on client machine you need to do it in Flex only.

Though I am not able to understand your requirement properly, can you elaborate it.

Regards
Amit Kr Pandey

Gerald Anto Fernando

unread,
Nov 23, 2010, 6:30:36 AM11/23/10
to flex_delhi_...@googlegroups.com
Actually i call a jsp file(from HttpService) which will call java function. that java function will open notepad. this is my reuirement.
i did it in eclipse it is working but when i call that jsp file from tomcat(not in eclipse) the notepad will not open.
it it pen i can easily call the file from flex httpService Request.
at present this is my problem give me an idea .
or Is there anyway to do this
please help me AMIT

Thanks&Regards,
Gerald A

Gerald Anto Fernando

unread,
Nov 24, 2010, 2:14:08 AM11/24/10
to flex_delhi_...@googlegroups.com
i used blaze ds to call java method.
but i got the following error please give me solution friends

[MessagingError message='Destination 'CreatingRpc' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']

AMIT PANDEY

unread,
Nov 24, 2010, 2:35:43 AM11/24/10
to flex_delhi_...@googlegroups.com
You this error is saying that you have not define the channel in the remoting-config.xml or that channel you defined is not available in the given package. It would be gr8 if you can share your project source, That will help us to understand the problem.

Regards
Amit Kr Pandey
+91-9873904496



Gerald Anto Fernando

unread,
Nov 24, 2010, 5:53:02 AM11/24/10
to flex_delhi_...@googlegroups.com
hi Amit the following are my code and config files


remoting-config xml


<?xml version="1.0" encoding="UTF-8"?>
<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>
    -->
    <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint url="http://localhost:8080/MyApplication/messagebroker/amf"
         class="flex.messaging.endpoints.AMFEndpoint"/>
         <properties>
         <polling-enabled>false</polling-enabled>
        </properties>
    </channel-definition>
   
    <destination id="CreatingRpc">
    <properties>
    <source>com.adobe.remoteobjects.RemoteServiceHandler</source>
    </properties>
    <adapter ref="java-object"/>
    </destination>
</service>

MyApplication.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.controls.Alert;

]]>

</mx:Script>

<mx:RemoteObject id="remObj"

destination="CreatingRpc"

result="Alert.show(event.result.toString());"

fault="Alert.show(event.fault.faultString);"

/>

<mx:Button id="remoteService" label="Remote Service" click="remObj.getResults('Sujit');"/>   
</mx:Application>

RemoteServiceHandler

package com.adobe.remoteobjects;
import java.util.Date;
public class RemoteServiceHandler {

    public static void main(String args[])
    {   
        System.out.println("Example of RemoteServiceHandler");
    }
    public  RemoteServiceHandler()
    {
    }       
    public String getResults(String name)
    {
    String result = null;
    result = "Hi " + name + ", this is a service and the time now is : " + new Date();
    return result;
    }

}

Root Folder:C:\Program Files\Tomcat\webapps\MyApplication
Root URL:http://localhost:8080/MyApplication/
ContextRoot:/MyApplication

Gerald Anto Fernando

unread,
Nov 26, 2010, 3:03:22 AM11/26/10
to flex_delhi_...@googlegroups.com

thank you friends ans mr.Amit, now flex-java objects is working fine.
thanks for all
Reply all
Reply to author
Forward
0 new messages