10 Replies Latest reply on May 25, 2010 10:33 AM by cheftimo

    FB4 - action script code generation issue

    srini@orlando

      Created a java pojo with boolean attribute on backend .
        For example like this,
        public class CustomerBO {

      private boolean isFunction;

      public boolean isFunction() {
      return isFunction;
      }

      public void setFunction(boolean isFunction) {
      this.isFunction = isFunction;
      }

      public CustomerBO() {

      }
        }

      2. Create a remote service that returns this object.

      3. using FlashBuider connect to this service , it generates action script classes (valueobjects & service classes ).
         But it's not compiling , we don't know how it generates.

         Looks like , isFunction method translated into as below , since function is a reserved word, it's not compiling.
        
         [Bindable(event="propertyChange")]
          public function get function() : Boolean
          {
                  return _internal_function;
          }

      We are trying to connect to existing backend system which has functions like this isFunction , isNull etc... ,

      Is there any work around ?

        • 1. Re: FB4 - action script code generation issue
          srini@orlando Level 1

          Any one knows , how FlashBuilder generates ActionScript code from remote java classes. In above case do i have option to modify the generation logic by introducing any kind of plugins.

           

          We are trying to connect to existing legacy system , which has methods like this , getIsFunction , getIsNull etc.. ,

          It would be a significant effort to modify these functions on backend. Why FB ignoring 'IS' word.

           

          Please share your thoughts.

           

          Thanks for your time.

           

           

          It's been 2 days , no help from forums or on adobe jira site ( i opened bug on this ). I thought adobe employees are monitoring these sites.

          I want to know , if i m missing some thing here or it's really a bug.

          • 2. Re: FB4 - action script code generation issue
            srini@orlando Level 1

            We are planning to re-think about our decision to go with FLEX.

            I opened bug on this issue and posted on these forums , but no response from adobe employees.

            • 3. Re: FB4 - action script code generation issue
              alexlizn Level 1

              I'm not an expert. Actually, I've being trying it these days.

               

              since you already have Java code created, you can use it through Data Service. As for me, I use BlazeDS/Java RMI to tap into my Java Code. For example:

               

              http://www.adobe.com/devnet/flex/articles/flashbuilder4_blazeds.html

               

              After your Data Service setup, you can just use your Java code. There is no need to do it over in Activescript.

               

              just my 2 cents.

              • 4. Re: FB4 - action script code generation issue
                srini@orlando Level 1

                Hi Alex,

                 

                When we create DataService , FlashBuilder generates these service and valueobject classes , these generated classes won't compile , if your remote java class has a function like this getIsFunction() , getIsNull() . Bcoz these are get translated into get function() and get null().

                 

                Since function and null are keywords , the action script classes won't compile.

                 

                Thanks

                Srini-

                • 5. Re: FB4 - action script code generation issue
                  alexlizn Level 1

                  Srini,

                  Can you post the source code? That would worth a thousand words.

                  • 6. Re: FB4 - action script code generation issue
                    srini@orlando Level 1

                    Hi Alex,

                     

                    Here you go.

                     

                    CustomerBO pojo:

                     

                    public class CustomerBO {

                    private String firstName;
                    private String lastName;
                    private String email;
                    private boolean isFunction;

                    public boolean isFunction() {
                      return isFunction;
                    }

                    public void setFunction(boolean isFunction) {
                      this.isFunction = isFunction;
                    }

                    public CustomerBO() {
                     
                    }

                    CustomerBO(String firstNameArg, String lastNameArg,String emailArg) {
                      this.firstName = firstNameArg ;
                      this.lastName = lastNameArg ;
                      this.email = emailArg ;
                    }
                    public String getFirstName() {
                      return firstName;
                    }
                    public void setFirstName(String firstName) {
                      this.firstName = firstName;
                    }
                    public String getLastName() {
                      return lastName;
                    }
                    public void setLastName(String lastName) {
                      this.lastName = lastName;
                    }
                    public String getEmail() {
                      return email;
                    }
                    public void setEmail(String email) {
                      this.email = email;
                    }

                     


                    }

                     

                    Remote Service class:

                     

                    public class RemoteService {

                    List<CustomerBO> customerList = new ArrayList<CustomerBO>();

                      public List<CustomerBO> getAllCustomers() {
                      customerList.add(new CustomerBO("Jeff","ABC","jeff.avc@att.com"));
                      customerList.add(new CustomerBO("Srini","DEF","srini.def@att.com"));
                     
                      return customerList;
                    }

                    public String registerCustomer(String firstName, String lastName, String email) {
                      System.out.println("name: "+ firstName);
                      System.out.println("emai: "+email);
                      customerList.add(new CustomerBO(firstName,lastName,email));
                      return "customer created successfully"; 
                    }

                    public String registerCustomerBO(CustomerBO customer) {
                      System.out.println("first name: "+ customer.getFirstName());
                      System.out.println("last name: "+ customer.getLastName());
                      System.out.println("emai: "+customer.getEmail());
                      customerList.add(customer);
                      return "customer created successfully"; 
                    }

                     

                    Using FlashBuilder dataservices feature ( BlazeDS ) connect to this remote class. FB generates action script classes. These generated classes won't compile .

                     

                    Bcoz it doesn't translate correctly.

                     

                    [Bindable(event="propertyChange")]
                        public function get function() : Boolean   
                        {
                                return _internal_function;
                        }  

                     

                     

                    Thanks

                    Srini-

                    • 7. Re: FB4 - action script code generation issue
                      alexlizn Level 1

                      Srini,

                      you don't have getFunction() in your Java class CustomerBO.   I think this is the reason. I'm an Oracle DBA, but I know that every Java class has both setter and getter for each variable.

                       

                      Looks like FB assumes you have both setter and getter in your Java class.

                      • 8. Re: FB4 - action script code generation issue
                        srini@orlando Level 1

                        Alex ,

                         

                        My backend system had 2 getter methods for isFunction variable.

                        getIsFunction()  -> translates correctly into get isFunction() ( java - action script ).

                        But the other funtion isFunction() which we need for backend serialization purposes, it doesn't translate correctly.

                        isBooleanVariable() -  this getter method convention is common for java boolean variables.

                         

                         

                         

                        isFunction()   ->  translates incorrectly into public function get function() : Boolean.

                         

                        It would be helpful , if we need know how FB/BlazeDS inspects these java classes and generates action script code.

                         

                        Thanks

                        Srini-

                        • 9. Re: FB4 - action script code generation issue
                          alejandrorrr

                          If you ask me this is the typical pushing the square peg in a round hole situation. My recommendation? Create and Adapter Pattern for the existing Java Class and then use BlazeDS for Remoting.

                          • 10. Re: FB4 - action script code generation issue
                            cheftimo Level 2

                            It's been 2 days , no help from forums or on adobe jira site ( i opened bug on this ). I thought adobe employees are monitoring these sites.

                            I want to know , if i m missing some thing here or it's really a bug.

                             

                            Get used to it. I am by no means a full-fledged developer, but I like to create my own (little) websites/projects. I know nothing about Java, but I do know a little about using Flex and ColdFusion together. From what I have seen, the Adobe people will respond to issues like this when it gives them a chance to push this “Data-centric” product, which I view as a marketing tool for them – just imagine: a short-order cook can now “create an app in an hour”, complete with DB connections and all kinds of fancy stuff. Look ma, I quit McDonalds; I’m a developer now.

                             

                            Don’t give up on Flex, though; you can create some really nice, useful things with it. But just sit down and do it with plain old ActionScript and MXML code. Writing your own AS value and back-end objects will take you less time than just reading all these generated VOs, which might as well be written in Chinese. The ActionScript WYSIWYG tool is far from finished – maybe eventually we’ll have a decent one, but it ain’t here now. The Bug Builder engineers don’t know how, or don’t want to, deal with it. I have a hunch that soon this is all going to come back and bite them in the AS*.

                             

                            Anyway, that’s my two cents. Regards,

                             

                            Carlos