cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Bowser (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (CB-2085) Database Deleted when I open childbrowser
Date Thu, 03 Jan 2013 18:20:13 GMT

     [ https://issues.apache.org/jira/browse/CB-2085?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Joe Bowser resolved CB-2085.
----------------------------

    Resolution: Fixed

Slated for 2.4.0
                
> Database Deleted when I open childbrowser
> -----------------------------------------
>
>                 Key: CB-2085
>                 URL: https://issues.apache.org/jira/browse/CB-2085
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 2.1.0, 2.2.0
>         Environment: Android, Phonegap,
>            Reporter: Ismael Olusola Jimoh
>            Assignee: Joe Bowser
>             Fix For: 2.4.0
>
>         Attachments: 2013-01-03-15-56-57-152.png, 2013-01-03-15-57-03-482.png, 2013-01-03-15-57-10-684.png,
2013-01-03-15-57-20-843.png, 2013-01-03-15-57-30-553.png, 2013-01-03-15-57-40-449.png, 2013-01-03-15-57-54-341.png,
2013-01-03-15-58-23-263.png, 2013-01-03-15-58-30-526.png, 2013-01-03-15-58-37-306.png, 2013-01-03-15-58-51-725.png,
2013-01-03-15-58-59-568.png, Phonegap2_3_Test.rar
>
>
> Created an app where on the first page, user creates and enters values into a table,
upon success, he is sent to a second page which Contains a link to Google using Childbrowser
as well as a button to show content of database.
> If user clicks button to show content of database immediately he gets to page 2, the
result is as expected but if he should click button to childbrowser, when he closes and clicks
the result button, it states table does not exist returning *Error: Undefined*
> However, if user goes back to page one and recreates the whole table as well as enter
the values, then clicks childbrowser, return and click return button, it starts working.
> All subsequent visits also work provided you do not clear data/cache.
> Below is a code that can be used to reproduce this:
> ----------------------------------------------------------------------------Main.html
(Page1)
> ----------------------------------------------------------------------------
> <!DOCTYPE HTML>
> <html>
>   <head>
>     <meta name="viewport" content="user-scalable=no,width=device-width" />
>     <meta http-equiv="Content-type" content="text/html; charset=utf-8">
>     <script src="cordova-2.1.0.js" type="text/javascript"></script>
>     <script type="text/javascript" charset="utf-8" src="main.js"></script>
> 	<script src="jquery-1.8.2.min.js" type="text/javascript"></script>
>    <script src="jquery.mobile-1.2.0.min.js" type="text/javascript"></script>
>    <link rel="stylesheet" href="jquery.mobile-1.2.0.css" type="text/css" media="screen"
title="no title" charset="utf-8">
>    
>     <script type="text/javascript">
>     var DBObject;
>     function DoDBFunctionality() {
> 		try {
> 			DBObject = window.openDatabase("TestDB", "1.0", "TestDataBase",1024 * 1024 * 2);
> 		} catch (ex) {
> 			alert("in catch" + ex.message);
> 		}
> 		DBObject.transaction(insertIntoDB,onError,onSuccess);
> 		function insertIntoDB(tx) {
> 			var name = "Vaibhav";
> 			//tx.executeSql('DROP TABLE IF EXISTS TestTable');
> 			tx.executeSql('CREATE TABLE IF NOT EXISTS TestTable (id unique PRIMARY KEY, data)');
> 	        tx.executeSql('INSERT INTO TestTable (data) VALUES ("First row")');
> 	        tx.executeSql('INSERT INTO TestTable (data) VALUES ("Second row")');
> 			//alert("In Insert Function");
> 		}
> 		function onSuccess() {
> 			alert("Insertion in DB is successfull");
> 			window.open("index1.html");
> 		}
> 		/*
> 		 * If DB throws an Error
> 		 */
> 		function onError(err) {
> 			alert("Error is : " +err.message);
> 		}
> 	}
> 	</script>
> 	<style>
> 	
> 	</style>
>   </head>
>   <body  >
>  <h1>Hello DB</h1>
> 	<input type="submit" name="DB" value="DB" onclick="DoDBFunctionality()" />
>   </body>
> </html>
> ----------------------------------------------------------------------------
> ----------------------------------------------------------------------------
> Index1.html(page2)
> ----------------------------------------------------------------------------
> <!DOCTYPE HTML>
> <html>
>   <head>
>     <meta name="viewport" content="user-scalable=no,width=device-width" />
>     <meta http-equiv="Content-type" content="text/html; charset=utf-8">
>     <script src="cordova-2.1.0.js" type="text/javascript"></script>
>     <script type="text/javascript" charset="utf-8" src="main.js"></script>
>     <script src="jquery-1.8.2.min.js" type="text/javascript"></script>
>    <script src="jquery.mobile-1.2.0.min.js" type="text/javascript"></script>
>    <link rel="stylesheet" href="jquery.mobile-1.2.0.css" type="text/css" media="screen"
title="no title" charset="utf-8">
>     <script src="childbrowser.js" type="text/javascript"></script>
>     <script type="text/javascript">
>     
>     var DBObject //= window.openDatabase("TestDB", "1.0", "TestDataBase",1024 * 1024
* 2);
>   
>     function CB() {
>         /*
>          *To open Childbrowser window in application
>          */
>         var url = "http://www.google.com";
>         window.plugins.childBrowser.showWebPage( url, {showLocationBar: true});
>         //window.plugins.childBrowser.onClose();
>         window.plugins.childBrowser.onClose = closed;
>     }
>     
>      function closed() {
>              //location.reload();
>              //window.openDatabase("TestDB", "1.0", "TestDataBase",1024 * 1024 * 2);
>         }
>     function CallDB() {
> 		        try 
> 		        {
> 		            DBObject = window.openDatabase("TestDB", "1.0", "TestDataBase",1024 * 1024
* 2);
> 		        } 
> 		        catch (ex)
> 		        {
> 		            alert("in catch" + ex.message);
> 		        }
> 		        DBRetrieve();
> 		    }
> 		    function DBRetrieve() {
> 		        DBObject.transaction(retrieveIntoDB,onError,onSuccess);
> 		
> 		        function retrieveIntoDB(tx) {
> 		            tx.executeSql('SELECT * FROM TestTable',[],querySuccess1, onError);
> 		        }
> 		        function querySuccess1(tx,results) 
> 		        {     
> 		           /* alert("Returned rows = " + results.rows.length);
> 				  // this will be true since it was a select statement and so rowsAffected was 0
> 				 	 if (!results.rowsAffected) {
> 				    	alert('No rows affected!');
> 				    	return false;
> 				   }
> 				   alert("Last inserted row ID = " + results.insertId);*/
> 				  var len = results.rows.length;
> 				    alert("Demo table: " + len + " rows found.");
> 				    for (var i=0; i<len; i++){
> 				        alert("Row = " + i + " ID = " + results.rows.item(i).id + " Data =  " + results.rows.item(i).data);
> 				    }
> 		        }       
> 		        function onSuccess() {
> 		            
> 		        }
> 		
> 		        function onError(err) {
> 		            alert("Error is : " +err.message);
> 		        }
> 		    }
>   
>     
>         function nextpage() {
>        		CallDB();
>        }
>        
>     </script>
>     <style>
>     
>     </style>
>   </head>
>   <body  >
>   <h1>Hello ChildBrowser</h1>
> <input type="submit" name="CB" value="CB" onclick="CB()" /> 
> <br/> 
> <input type="submit" value="DBRetrieve" onclick="nextpage()" />  
> </body>
> </html>
> ----------------------------------------------------------------------------
> I have tested this on Phonegap 2.1 and 2.2.
> I have also tested this on Android 4.0, 4.2 and been able to reproduce on both.
> Thanks, I look forward to your quick response.
> Ismael O. Jimoh

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message