2 Replies Latest reply on Oct 9, 2009 1:56 AM by Ted Moens

    Importing Data Service with "bad" function names

    Ted Moens Level 1



      In a nutshell: In Flashbuilder beta 2, when you import a data service the action script code generation breaks if  there is a function name in the service that conflicts with an Action Script Keyword.  For example, if your Java class were to have a function called "toString".




      After a *lot* of time spent trying to get get Flexbuilder beta 2 to talk to BlazeDS. FlashBulider fcould see  and introspect all the example services from the BlazeDS turnkey samples.


      So I created a BlazeDS service to my "real" server classes.  Flexbuilder could see the service just fine, but it all came apart when I clicked Finish on the "Import BlaseDS/LCDS Service" dialog because my service has a "toString" function in it and that breaks the ActionScript code generation.


      Unfortunately the "toString" method is not written by me.  It is inherited from two layers deep in the ORM software in use on my server. (The software is Cayenne if you are curious.  It generates a lot of very useful objects based on a relational DB schema, but the generated objects inherit from the CayenneDataObject class which in turn inherits from the PersistentObject Class which has the nefarious "toString" method.)


      Given that I cannot change the Cayenne libraries - am I basically out of luck?


      Say it ain't so.



        • 1. Re: Importing Data Service with "bad" function names
          Balaji Sridhar Level 2

          Hi Ted,


          Thanks for your feedback.


          We have a similar issue https://bugs.adobe.com/jira/browse/FB-22767 being logged.


          Please vote for the same.


          Also refer to http://www.adobe.com/devnet/flash/articles/as_bestpractices_02.html





          • 2. Re: Importing Data Service with "bad" function names
            Ted Moens Level 1

            Thanks for your help.  I have a simple test class which demonstrates the problem quite succinctly.


            I wrote the following simple calss and made it a Blaze DS service:


            public class AAATest{
                private static final long serialVersionUID = -6119074171439508158L;


                public String test() {
                    return "this works";
                public String test2() {
                    return "This works also: " + this.toString();



            It works just fine. Note that the class has a toString method which it inherited by virtue of extending the basic Java class Object.


            Then I add a third method which simply overrides the existing "toString" method inherited from Java's Object  class:



                public String toString() {
                    return "This does not work";


            Recompile etc. Now when I try to import the service (or refresh it) in FlashBuilder I get the foillowing message:


            ERROR [1]: ActionScript generation is not supported for  services containing functions or function arguments that clash with ActionScript  keywords. Service "AAATest" contains illegal function "toString".


            OK, so it looks like overriding "toString" is a problem - but it is a very normal thing to do on the Java side.