Design concern when using QC framework to do multiple call to handleRequest

0 views
Skip to first unread message

andrew.sky

unread,
Nov 18, 2009, 1:50:49 AM11/18/09
to QuickConnect
Hi Everyone,

I had created a javascript function
insertDATABCF(parameters, partialResults)
clearAllDataBCF(parameters, partialResults);

that can be called repeatedly to insert data into different tables
depending on the parameters defined. This is working as i had tested
out with different settings in the parameters.

I wanted to update 3 tables at the same time through the following
code which is not working in QC 1.5.1.

function syncTablesBCF(param) { // param contain information for
various table
for (var i=0; i < 3; i++) {
tableInfo = param[i] // prepare table information for
different table
handleRequest('syncTable',tableInfo);
}
displayStatus();
}

function displayStatus() {
// use javascript to display information to web page
}

The mapping.js is as follows:

mapCommandToBCF('syncTable', startTransactionBCF);
mapCommandToBCF('syncTable', clearAllDataBCF); //clear all table data
mapCommandToBCF('syncTable', insertDATABCF);
mapCommandToBCF('syncTable', commiTransactionBCF);

The above arrangement have strange effects on single table and
multiple table scenario.

Single Table scenario
- native database sqllite is populated correctly but displayStatus()
is not called. Should the displayStatus be part of the VCF in the
mapping ? If yes, then it will be called many time if i want to have
multiple table synchronization.

Multiple Table:
- e.g. if i have 3 tables, only the last table is populated. Again ,
displayStatus is not called.

As i had not migrated to use DBScript because of some issue with the
makeCall('runDBScript', in native access, can anyone offer some good
alternative ? The last thing i want to do is to dig into the framework
and do some hacking which violate the original intent of framework.

Please forgive if the above usage is not quite the right way to use
the framework. I have a feeling that the problem is due to the async
nature of the database call.

regards
Andrew


Jimmy

unread,
Nov 23, 2009, 12:26:55 AM11/23/09
to QuickConnect
I'm doing something similar right now. (Gonna try DBScript when I
upgrade to Snow Leopard). I handle it more like this:

mapCommandToBCF('syncTable', syncTableBCF);
mapCommandToVCF('syncTable', syncTableVCF);

function syncTableBCF() {
// Start Transaction
// Empty Table
// Loop the Inserts
// Commit Transaction
}

function syncTableVCF() {
// display info on web page
setTimeout("container.innerText='blah'", 12000);
}

When you display the info on the web page, use innerText, not
innerHTML. If you have to write HTML and not text, write the whole
DOM tree, and don't use innerHTML. Also comment out all your debug in
the VCF functions as this seems to kill anything you try to do on a
web page. If you put a debug message in the VCF function, you will
see that it gets called multiple times (each time per insert). I
think this is why there is a strange side-effect on how things get
rendered on the web page. That's also why I have it inside a
setTimeout, since the status will get rendered on the web page after
the 1st insert, not last. Put a debug message in your insert loop to
figure out how long the inserts will take .. then add like 5-10
seconds to make sure the inserts are finished before you go on. BTW,
the newer processors (3GS and the new ipod) have more powerful CPUs
and insert far faster than the older devices, so you'll have to
setTimeout for the older devices.

Sounds horrible right? It is!

Although I haven't used it yet, I would strongly suggest going in the
direction of using DBScript. I'm not sure what issue you are facing
with it, but if you can provide more details, Lee can probably help
you. makeCall('runDBScript') isn't any syntax I've seen in
QuickConnect.

Jimmy

Jimmy

unread,
Nov 23, 2009, 1:01:16 AM11/23/09
to QuickConnect
I saw your post in the other thread and understand what you mean now
by makeCall('runDBScript'). It seems that in 1.6b4 examples, all the
source code has been packaged into a library, so a Project Find for
(runDBScript) won't work. Not sure if you can open up the library and
look in it. Maybe if you post up your code for DBScript and post up
any error messages you're getting, someone else can help you.

Jimmy

Lee Barney

unread,
Nov 23, 2009, 12:06:33 PM11/23/09
to quickconn...@googlegroups.com
If you want to see the source code on the objective-c side for the runDBScript command you can.
  1. Install 1.6 beta 4
  2. Go to /Developer/QCLib
  3. Double click the QCLib.xcodeproj file
Or
  1. Install 1.6 beta 4
  2. Launch Xcode
  3. Create a new QCiPhone Application
  4. Double click the QCLib.xcodeproj sub-project located at the top of your new project.
The code is open and available for viewing.  It is best to use the DBScript functionality.  It is designed for exactly what you are attempting.  Other work arounds will be ugly because of the async messaging with the databases.  I wish I could make them synchronous but neither the iPhone nor Android platforms let me do that.

If you are using a native database the DBScript stuff passes one async message to the objective-c side containing all of the update statements you want executed.  It then executes them synchronously within a transaction against the database.

If you are using an in-browser database the behavior is much the same.


Lee

--

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



andrew.sky

unread,
Nov 26, 2009, 9:50:27 AM11/26/09
to QuickConnect
Unfortunately, 1.6 beta requires snow leopard right ? I encounter
installation error when i try to run the installer. Will there be
anyway to modify 1.5 code to include runDBScript command ?

regards
Andrew

On Nov 24, 1:06 am, Lee Barney <barney....@gmail.com> wrote:
> If you want to see the source code on the objective-c side for the
> runDBScript command you can.
>
>    1. Install 1.6 beta 4
>    2. Go to /Developer/QCLib
>    3. Double click the QCLib.xcodeproj file
>
> Or
>
>    1. Install 1.6 beta 4
>    2. Launch Xcode
>    3. Create a new QCiPhone Application
>    4. Double click the QCLib.xcodeproj sub-project located at the top of
> > quickconnectiph...@googlegroups.com<quickconnectiphone%2Bunsu...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages