Skip to main content

Jamki-google gears

5 replies [Last post]
raghavan1981
Offline
Joined: 2009-04-01
Points: 0

Hi I am new to Jmake, I have read in the net like Jmaki can be used with google gears to send local data to the server side component.

How this can be achieved and what are all the components needed for Jmaki ...

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gmurray71
Offline
Joined: 2003-07-31
Points: 0

The google gears extension looks like this:

Place a file with this content in /resources/google/gears/extension.js

jmaki.namespace("jmaki.extensions.google.gears");

jmaki.extensions.google.gears.Extension = function(args) {

var self = this;
var topic = "/google/gears";
var db = null;
var factory = null;
this.available = true;

this.postLoad = function() {
self.init();
jmaki.subscribe(topic + "/execute", self.execute);
};

this.init = function() {
jmaki.log("Google Gears jMaki 1.0 Extension intialized");

// Firefox
if (typeof GearsFactory != 'undefined') {
factory = new GearsFactory();
} else {
// IE
try {
factory = new ActiveXObject('Gears.Factory');
} catch (e) {
// Safari
if (navigator.mimeTypes["application/x-googlegears"]) {
factory = document.createElement("object");
factory.style.display = "none";
factory.width = 0;
factory.height = 0;
factory.type = "application/x-googlegears";
document.documentElement.appendChild(factory);
}
}
}
// Now set up the objects, being careful not to overwrite anything.
if (!window.google) {
window.google = {};
}

if (!google.gears) {
google.gears = {factory: factory};
}
};

// Open this page's local database.
function initDB() {
if (!window.google || !google.gears) {
jmaki.log("Google Gears not found.");
self.available = false;
return;
}

try {
db = google.gears.factory.create('beta.database', '1.0');
} catch (ex) {
jmaki.log('Could not create database: ' + ex.message);
self.available = false;
}

if (db) {
db.open('beta-database');
db.execute('create table if not exists jmakiwebtop' +
' (id varchar(256), obj varchar(19048))');
}
}

this.execute = function(args) {
this.query = args.query;
var _callback = args.callback;
this.qargs = args.args;
if (!db) initDB();
if (!db) {
jmaki.log("Google Gears Extension: Unable to find database");
self.available = false;
return;
}
var rs = db.execute(query, qargs);
// exectue callback if it's there
if (typeof _callback != 'undefined') _callback.call(this,rs);
};
};

Next in your JSP put:

To use:

Let me know if you have problems with it.

-G

raghavan1981
Offline
Joined: 2009-04-01
Points: 0

Hi Murray,

query: "select * from jmakiwebtop where id='" + _widget.webtopId

in this line "jmakiwebtop" denotes the local database name right?, which we created using beta.database in google gears.

raghavan1981
Offline
Joined: 2009-04-01
Points: 0

I have implemented everything that you have mentioned in this blog

http://weblogs.java.net/blog/gmurray71/archive/2007/06/jmaki_extension_1...

Update me abt whether it is local database(google gears) name or not?

raghavan1981
Offline
Joined: 2009-04-01
Points: 0

Hi Murray,

I have some doubts in regard to your blog...

1. No where in the sample you mentioned about the google gears database, then how it recognizes about the local database?
2. As you have mentioned in the blog i am not getting any save icon if i change the default value of the editor to "@{window.editorData}"
3. I want to save the data into the master database from the local database(google gears). How this is accomplished in jMaki, pls explain...

raghavan1981
Offline
Joined: 2009-04-01
Points: 0

Hi is there anyone to help me on this regard