Welcome to Open Discussion

2009-02-10
2013-04-29
  • Welcome to Open Discussion

     
    • john menke
      john menke
      2009-05-14

      Looking to participate in this project - what is currently needed?

       
    • Ed2910
      Ed2910
      2009-07-13

      My apologies if this is in the wrong place - I can't see where I can post a new topic.
      I am hugely impressed with cdb. Struggled a bit to get it configured right but my cbd installation is working fine set up as per the sql-based code generation option.

      I wanted to test autosync. I followed the article at http://flexblog.faratasystems.com/?p=398n. I regenerated using autoSyncEnabled=true - no errors. I ran as a flex project from Eclipse.
      When I make a data change and commit from one browser window, a different browser window displaying the data grid does *not* reflect the update (It does show after I press F5 to refresh).

      I'm thinking that maybe the sync feature only works if you run on the server, not as a flex project? (I can't run on the server in my current configuration of CDB so can't test this - I'm not a java expert so not sure how to change this)

      All suggestions welcome.

      Thanks,
      Ed

       
      • Ed,

        First please make sure autoSyns example works - I refer to the grid based example Employee_getEmployees_GridTest.mxml.

        If so, you have the late enough version of plugin and can proceed further.
        Next, check whether you have specified  keyColumn, updateTable and autoSyncEnabled on Java - similar to the com.farata.text.Employee.java.

        Finally, check whether you have specified autoSyncEnabled=true simlar to the abovementioned mxml file.

        That should do it.

        Kind Regards,
        Victor

         
        • Ed2910
          Ed2910
          2009-07-13

          Dear Victor,

          I really appreciate the quick response. 

          I believe I have done everything you mentioned.

          My simple app uses  a mysql table called users with a lowercase PK named id.

          To summarize:

          1. User_getUsers_GridFormTest_sync.mxml
          Works fine. I am able to update data and commit. The issue is that a second browser window does not show the update until you refresh the browser (f5)

          2. I copied User.java from Employee.java as given below.

          I think my problem may be to do with Tomcat/Eclipse:

          After regenerating the application, I copy User_getUsers_GridFormTest_sync.mxml from test/rpc into the flex src folder. Then the option to run this file as a Flex Application is no longer shown on the Run As right click menu. (?)  Tomcat reports some problem with the context (which I do not understand). Tomcat  now seems to have gone unstable, does not respond to restart. Have to quit Eclipse.

          Q1. Is including autosync = true resulting in the Run As Flex Application not being shown, or is totally unrelated?
          Q2. What is this context problem, and how do I fix it? I'm a Tomcat newbie, but not a programming newbie - I'm 49, and when the kids don't keep me up at night, still have a few working brain-cells :-)

          Tx,

          Ed

          (I am new to Tomcat  - but not to programming - I'm 49 :-)

          Tx very much,

          Ed

          import java.util.List;
          /**
            * @daoflex:webservice pool=jdbc/mysql
          */   
          public abstract class User {

          /**
          * @daoflex:sql
          * pool=jdbc/mysql
          *  sql=::  select *
          *            from users
          *  ::
          *  transferType=UserDTO[]
          *  keyColumns=id
          *  updateTable=users
          *  autoSyncEnabled = true
          */
          public abstract List getUsers();
          }

           
        • Ed2910
          Ed2910
          2009-07-13

          Dear Victor,

          I really appreciate the quick response. 

          I have I done everything you mentioned.

          When I run as a Flex application:

          http://localhost:8080/ntc1/User_getUsers_GridFormTest_sync.html

          from two browsers, it all works fine, but the autosync does not work.

          I was experiencing some problems with Contexts being reloaded (whatever that means :-), and Tomcat hanging and reporting errors, but I have got past this by stopping Tomcat before copying the User_getUsers_GridFormTest_sync.mxml from test/rpc into the flex src folder.

          Q1. Do I have to  Run on Server (rather than run as Flex application) for AutoSync to work?
          (I tried to do this, but get an http 404 error: not available error)

          Tx very much,

          Ed

           
          • Ed,

            I mentioned test running examples coming with ClearDB. You say you have done everything I mentioned, I assume you have working sample of the autoSyncEnabled, albeit on our database.

            Let me check this explicitly: have you made sure that  CDB autoSync examples work in your installation? I mean our code, our MySQL database.

            Kind Regards,
            Victor

             
            • Ed2910
              Ed2910
              2009-07-14

              Hi Victor,

              Thank you again for your prompt response.

              You asked me to install your sample running your mysql db for autosync example.
              Not sure what you mean. I don't see a mysql example, only db2, and no autosync example in the main documentation.

              I have been following the article "data synchronization in a multi-user environment" - I have found nothing else.

              I have a working cdb environment (after many weeks), only autosync not working, surely can go forward with it?

              I can see where the autosync is failing but don't know how to fix it.
              My User.java file is a virtual copy of Employee.java, as given below.
              The ONLY change I introduced to get the AutoSync working was to add the line:

              *  autoSyncEnabled = true

              From the documentation I believed adding this line was *all that is required*.

              Is that correct????

              I ran cdb, but the generated User_getUsers_GridFormTest.mxml does *not* contain:

              collection.autoSyncEnabled = true.

              as indicated in the documentation.

              In fact when I tried to type it manually into the file, the intellisense did not find autoSyncEnabled...

              So obviously the autosync functionality is not working...

              I am v keen to persist with this technology: I think it has a very bright future.

              When I get the autosync working, I will happily contribute an article to assist others...

              Best regards,

              Ed

              User.java.

              package com.ecw;

              import java.util.List;
              /**
                * @daoflex:webservice pool=jdbc/mysql
              */   
              public abstract class User {

              /**
              * @daoflex:sql
              * pool=jdbc/mysql
              *  sql=::  select *
              *            from users
              *  ::
              *  transferType=UserDTO[]
              *  keyColumns=id
              *  updateTable=users
              *  autoSyncEnabled = true
              */
              public abstract List getUsers();
              }

               
              • Ed,

                All points to the outdated plugin version, I assume March 29 or something like that.

                Please remove all farata jars and folders from eclipse/plugins and eclipse/features and install the newest version of the plugin. Create a new project for CDB samples, it should work. Then create another new project for your stuff and copy over the Java sources from your old CDB project - this is the safest migration path.

                Kind Regards,
                Victor

                 
                • Ed2910
                  Ed2910
                  2009-07-14

                  Ok Victor, I'll try that.

                  Best regards,

                  Ed

                   
                  • Ed2910
                    Ed2910
                    2009-07-15

                    Thanks v much Victor  - I installed the latest version of the plugin and my autosync is working!
                    Regards, Ed

                     
    • Ed2910
      Ed2910
      2009-07-28

      Hi Viktor,

      I need to be able to modify my sql query on the fly, and was looking into the sqlCallBack annotation.
      I created my own example called User.java copied from Employee.java  example and load User_searchUsers_GridFormTest successfully.

      However, when I fill in the context text field with : {where: "id=1"} and click the Fill button

      I get the following error:

      Error on destination: com.ecw.User:
      java.lang.String cannot be cast to java.util.Map

      I can't figure out what input is required to the context text, or what else might be the problem.

      (Note that User_getUsers_GridFormTest runs fine, so the db table is not the problem).

      Thanks,

      Ed

      My User.java is:

      package com.ecw;

      import java.util.List;
      import java.util.Map;
      /**
        * @daoflex:webservice pool=jdbc/mysql
      */   
      public abstract class User {

          /**
          * @daoflex:sql
          * pool=jdbc/mysql
          *  sql=::  select *
          *            from users
          *  ::
          *  transferType=UserDTO[]
          *  keyColumns=id
          *  updateTable=users
          *  autoSyncEnabled = true
          */
          public abstract List getUsers();
         
          /**
          * @daoflex:sql
          *  sql=::  select * from users
          *  ::
          *  transferType=UserDTO[]
          *  updateTable=users
          *  keyColumns=id
          *  tag=sqlCallback:modifyGetUserSQL
          */
          public abstract List searchUsers(Map context);

          protected String modifyGetUserSQL(Map context, String sql) {
              // Whatever you feel like doing with the SQL
              String whereClause = (String)context.get("where");
              if (whereClause != null) {
                  return sql + " WHERE " + whereClause;
              } else {
                  return sql;
              }
             
          }

      }

      Note: I used my own example because after many hours of trying, and repeated installations of the example database I continue to  get an "unable to run xxxx_sync error when I attempt a commit. I am running mysql 5, and "guessed" to create a database called test before running the installation.... I would love to be able to run the examples.)

       
      • Ed,
        I suggest to hardcode fill({where:"id=1"}).
        You will not be able to enter it via test input field.
        Otherwise it gets treated as String instead of Object.

        Kind Regards,
        Victor

         
        • Ed2910
          Ed2910
          2009-07-29

          Thanks Viktor - it works. For the benefit of anyone reading this posting, I actually did use the context input string, and modified the fill_onClick code to:

          var objEcw:Object
          objEcw.where = param_searchUsers_context.text;   
          collection.fill(objEcw);

          Now you can fill in  a where property of arbitrary complexity in  the context box such as:

          first like 'e%' and id > 2

          and click on the Fill button.

          Ed