1 Reply Latest reply on Aug 8, 2007 7:16 AM by AndyWW

    Pure java Object

      hi all
      can any body describe me how to access a pure java object in flex such that i can use it to call those java object methods.
        • 1. Re: Pure java Object
          AndyWW
          There are a few basic concepts that you will need in order to communicate with a Java method from a Flex client to the web server. I purchased the somewhat pricey book "Adobe Flex & Java" by Yakov Fain et al, and this helped considerably with the process (notably chapter 7). Basically, you will need configure a few things in the web server and put your Action Script and Java files into the web server paths (under Tomcat there is a directory named WEB-INF/classes for the Java ".class" files, and a directory named WEB-INF/flex/user_classes for the AS ".as" files). You may have to change the flex/services-config.xml file to set the correct "login-command" server (to Tomcat, in my case), and the flex/remoting-config.xml file to add the mapping of your logical destination name (used in the AS class) to the actual qualified Java class name. The entry in the remoting-config.xml file is identifying your remote method that will be invoked from the AS RPC request.

          In AS you will need to instantiate a RemoteObject object and set the destination class to the logical destination name (identified in the remoting-config.xml file). The method that will be invoked is identified in the RemoteObject "getOperation()" AS method. Simply pass any parameters that you need for the Java method through the "send()" method against the operation object that is returned from the getOperation() call. You will also need to register event listeners against the RemoteObject. When you add the event listeners you will specify the callback method for successful and failed requests.

          I hope this gives you some idea of how to invoke Java from Flex ... it really isn't difficult, especially after you've done it once. There are some tutorials available, although I found the RIA book that I mentioned earlier to be the most useful in gaining a better grasp on this.

          Andy