07-19-2010 03:18 AM
HI,
I am trying to make a Sqlite project using gears API. I have downloaded the gears_init.js file locally. The sample application for Gears povided by BB is woking fine. But when I am tring to modify the same & use in my application the javascripts do not load. The index.heml page is loaded but none of the javascripts are invoked.
BB simulator : Storm 9550, 5.0.0.469
Browser :blackberry
N/w : both CDMA & GSM
THe index.html file:
title>Data Storage Example</title>
<link href="Styles/styles.css" rel="stylesheet" type="text/css" />
<script src="http://www.google.com/jsapi?key=ABQIAAAAsm1sbQmJWb gLoP7i4K2WdBR_SoAUqeLrvjUVmFG1nkbo-KiRrxRswNhze0oP ..." type="text/javascript"></script>
<script src="Scripts/action.js" type="text/javascript"></script>
<script src="Scripts/gears_init.js" type="text/javascript"></script>
<script type="text/javascript">
function myAlert(){
alert("Alert from HTML");
}
</script>
</head>
<body onload="javascript: demoAlert(); myAlert(); openDatabase(); populateShoppingListTable()">
<div>
<p class="header">Save shopping list items</p>
</div>
<div>
<p class="listTitle">Items</p>
<input type="text" id="txtItem" />
<br/>
<br />
<input type="button" value="Add item to list" onclick="addShoppingListItem(document.getElementBy Id('txtItem').value)" />
</div>
The action.js file:
// Global handle to the database
var _db;
// Open the database using Google Gears API and create a table if needed
function openDatabase() {
alert("kasiey ho anna");
var db = google.gears.factory.create('beta.database1');
db.open('itemSet1');
db.execute('create table if not exists ShoppingListTable (Serial text unique, ItemName text, PurchaseStatus text, Rate text, Qauntity text)');
_db = db;
}
function demoAlert(){
alert ("I am a jokings");
}
// Save the selected Items
/*function saveItems(item) {
try {
// Add the link into the database if the checkbox is checked
_db.execute('insert into Items values (?)', [item]);
// Update the table
populateTable();
}
catch (e) {
alert(e);
}
}*/
function addShoppingListItem(itemname) {
try {
alert(itemname);
var count = _db.execute('Select COUNT(ItemName) from ShoppingListTable');
var serialNum = count+1;
// Add the link into the database if the checkbox is checked
_db.execute('insert into ShoppingListTable (Serial, ItemName) VALUES ('+ serialNum + ', '+itemname+')');
//@@@@@@@@@@@@@@@@@Select COUNT(Supplier_ID) from suppliers
// Update the table
populateShoppingListTable();
}
catch (e) {
alert(e+"In add Shopping Item");
}
}
Solved! Go to Solution.
07-19-2010 09:39 AM
Check your onload statement
<body onload="javascript: demoAlert(); myAlert(); openDatabase(); populateShoppingListTable()">
what does "javascript:" perform?
07-19-2010 10:58 AM
Also, I believe that:
"google.gears.factory.create('beta.database');"
is a fixed term, so you cannot change the classname to "beta.database1".
If you want to change the database name, you have to change the parameter for "db.open('database1')".
I think, this one will cause problems, too - I may be wrong, though.
_db.execute('insert into ShoppingListTable (Serial, ItemName) VALUES ('+ serialNum + ', '+itemname+')');
Instead use:
_db.execute('insert into ShoppingListTable (Serial, ItemName) values (?,?)', [serialNum, itemname]);
08-20-2010 03:29 AM
Along with this I also had to change some other JScripts which were giving errors.
07-24-2011 06:35 AM