Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Visitor
rudi1008
Posts: 1
Registered: ‎12-30-2012
My Device: Rudi Bold 9000

Using HTML 5

Dear All Expert,

 

I already try to build application using html 5 and try some sample that already post in this forums but still can't access the database, but i already create the application and running in android device and it already success.

 

Below is the sample i download from this forum :

 

<script type="text/javascript" src="script/soapclient.js"></script>

        <script type="text/javascript" src="script/cordova-1.9.0.js"></script>

        <script type="text/javascript">

              

               //Wait for Cordova to load

           document.addEventListener("deviceready", onDeviceReady, false);

 

            //Cordova is loaded and it is now safe to make calls Cordova methods

           

            function onDeviceReady()

            {

                 

                checkConnection();

            }

       

            function checkConnection()

            {

                var networkState = navigator.network.connection.type;

       

                var states = {};

                states[Connection.UNKNOWN]  = 'Unknown connection';

                states[Connection.ETHERNET] = 'Ethernet connection';

                states[Connection.WIFI]     = 'WiFi connection';

                states[Connection.CELL_2G]  = 'Cell 2G connection';

                states[Connection.CELL_3G]  = 'Cell 3G connection';

                states[Connection.CELL_4G]  = 'Cell 4G connection';

                states[Connection.NONE]     = 'No network connection';

               //alert('Connection type: ' + states[networkState]);

                       if(states[networkState]=="No network connection")

                       {

                               alert("No Connection Available ");

                               navigator.app.exitApp();

                       }      

               }

               var stationList = new Array;  

            

               function GetStationCodes()

               {   

                       document.getElementById('loadingImg').style.visibility = "visible";

                      

                    var pl = new SOAPClientParameters();

                    var parameter1 = "";

                    var parameter2 = "";

                    pl.add("parameter1", parameter1);

                    pl.add("parameter2", parameter2);

                    SOAPClient.invoke(WSDLURL, "stationSearch", pl, true, GetStationCodes_callBack);

               }

               function GetStationCodes_callBack(r)

               {

                       document.getElementById('loadingImg').style.visibility = "hidden";

                       document.getElementById('submitBtn1').removeAttribute('disabled');

                       document.getElementById('submitBtn2').removeAttribute('disabled');

                       document.getElementById('getStationDesc').removeAttribute('disabled');

                       for (var i = 0; i < r.length-1; i++)

               {

                       stationList[i] = r[i].stationCode + " - " + r[i].stationName;// i download complete

               }

               var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);// create data base*********

            db.transaction(populateDB, errorCB, successCB);*****call function

               }      

               function SetAction(flag)

               {

                       if(flag==1)

                       {

                                document.frmIndex.action="arrival.html";

                       }

                       else

                       {

                                document.frmIndex.action="departure.html";

                       }

               }

              

              

               function populateDB(tx) {

         tx.executeSql('DROP TABLE IF EXISTS DEMO');

         tx.executeSql('CREATE TABLE IF NOT EXISTS STATIONLIST (id unique, data)');

       for (var i = 0; i <stationList.length-1 ; i++){

         tx.executeSql('INSERT INTO DEMO (id, data) VALUES (i,stationList[i] )');// is it correct..?

        

       }

    }

 

    // Transaction error callback

    //

    function errorCB(tx, err) {

        alert("Error processing SQL: "+err);

    }

 

    // Transaction success callback

    //

    function successCB() {

        alert("success!");

    }

 

        </script>

</head>

<body onload="GetStationCodes()"> ********Here i download list******

 

My simple questions is "How to connect the database in blackberry using html 5 ?". Please help me and thanks so much for the great support.

 

Regards

Rudi