Page 4 of 4 FirstFirst 1234
Results 61 to 68 of 68
  1.    #61  
    Shawalli,

    If you've never used SQL before then I'd probably first do a google and take some of the basic tutorials out there for creating tables, inserting into tables, selecting from tables and deleting. It'll give you some good background knowledge.
  2. #62  
    Apple, who develops on webkit and contributes heavily on webkit, has a good pdf on it. It took me a lot of work to find it.

    Hope it helps

    Safari Client-Side Storage and Offline Applications Programming Guide: Relational Database Basics
  3. shawalli's Avatar
    Posts
    83 Posts
    Global Posts
    85 Global Posts
    #63  
    using the data app example in the sdk does wonders for understanding for anyone else listening, its a really big help
  4. #64  
    Quote Originally Posted by worthb View Post
    Have you tried using anonymous functions for the result and error functions as shown in the last example on this webpage?Mojo Storage Database - WebOS Internals

    As noted earlier on that page:
    The examples given in that tutorial are an absolute mess. There are several errors in it and it most certainly is possible to use declared functions as handlers. Using anonymous functions is not the best idea. About the only thing marginally useful in that entire tutorial is the bit about how to create a table and even that has errors in it.

    The Apple tutorials and the examples in the WebOS docs are much better. As someone else pointed out, the Data sample app is also a very good source for information.
  5. shawalli's Avatar
    Posts
    83 Posts
    Global Posts
    85 Global Posts
    #65  
    has anyone tried the data app thats included in the sdk? I'm up to the point where I can create a DB, create a table, and create a row. The problem lies in querying the table/row. There is a "pop_button" listener created in the query-assistant, but no button in the scene. If I'm reading it right, I think the list container and list item get popped back into the query assistant, where they are used to display the query results. When I include the listener and listener handler, however, my app freezes up. Am I doing something wrong and/or is there another way to query the table than the example in the data app?
  6. #66  
    Great help,

    Thank you guys this helped me get the scoreboard working on the DropBlock. Feel free to ask me for a beta copy of the game DaveInFL, yiffzer & deCorvett.
  7. shawalli's Avatar
    Posts
    83 Posts
    Global Posts
    85 Global Posts
    #67  
    nevermind, [my brother] figured it out...the pop button is actually the back button to return to the main SQL screen. In my frustration I had exactly copy-and-pasted palms code into my app just to see if it could get it working using their coding practices. Turns out I forgot to change the assistant name in the activate and deactivate functions. Copying and pasating turned out to be more of a hassle than a blessing
  8. #68  
    Hello deCorvett / DaveInFL,

    I have the similar problem, Iam sure anyone of you can help me out their. please help me.
    I want to retrieve and display the records in a list. Below is my code;

    My savefav-assistant.jsjsjs $file$

    Code:
    function SavefavAssistant(textval) {
    	this.textString = textval;
    }
    
    SavefavAssistant.prototype.setup = function() {
    	
    	var name = "PreDB"; // required
    	var version = "0.1"; // required
    	var displayName = "Pre database"; // optional
    	var size = 100000; // optional
    	var db = openDatabase(name, version, displayName, size);
    	
    	// The following just sets up the nice list box for the results of a query.
    	this.innerListAttrs = {
    		listTemplate: "savefav/mainListTemplate",
            itemTemplate: "savefav/mainRowTemplate"  
    		
        };
    	
    	this.resultList = []
        this.listModel = {            
            items: this.resultList
        };
    	//this function gets the data from the DB	
    this.getlist(this);	
    
    this.controller.setupWidget('results_list', this.innerListAttrs, this.listModel);
    this.controller.listen('results_list', Mojo.Event.listTap, this.handlePop.bindAsEventListener(this));
    
       // Mojo.Event.listen($('pop_button'),Mojo.Event.tap, this.handlePop.bind(this))
        
    }
    
    SavefavAssistant.prototype.getlist = function(event){
    	
    var string = 'Select id, data from pretest';	
    this.db.transaction( 
            (function (transaction) { 
                transaction.executeSql(string, [], this.handleresults.bind(this), this.errorHandler.bind(this));}).bind(this));
    
    }
    
    SavefavAssistant.prototype.handleresults = function(transaction, results) {    // success handler
    //Clean again the array to prevent duplicates in list
    this.rowsArray= [];
    
    	if (results.rows.length > 0) {
    		for (var i = 0; i < results.rows.length; i++) {
    
    //Processes the data. Asign variables to the row items, I've found storing directly on the array causes problems with values
    
    			row_fieldName = results.rows.item(i).id;
    			row_fieldName2 = results.rows.item(i).data;			
    
    //Insert data into the array	
    		
    			this.rowsArray.push({
    				FieldName: row_fieldName,
       	    			FieldName2: row_FieldName
    		       		});
    
    			}
    
    //Insert the data in the resultList
    
    		this.resultList.clear();
    		Object.extend(this.resultList,this.rowsArray);
    		this.controller.modelChanged(this.listModel, this);
    
    	}
    	else {
    		//ERROR HANDLING: NO RECORDS
    	}    
        
    }
    
    SavefavAssistant.prototype.handlePop = function(){
    	//pop the current scene off the scene stack
    	Mojo.Controller.stageController.popScene();
    }
    
    SavefavAssistant.prototype.activate = function(event){
    	/* put in event handlers here that should only be in effect when this scene is active. For
    	 example, key handlers that are observing the document */
    	// Query table1
    }
    
    
    SavefavAssistant.prototype.deactivate = function(event) {
    	/* remove any event handlers you added in activate and do any other cleanup that should happen before
    	   this scene is popped or another scene is pushed on top */
    }
    
    SavefavAssistant.prototype.cleanup = function(event) {
    	/* this function should do any cleanup needed before the scene is destroyed as 
    	   a result of being popped off the scene stack */
    }
    
    SavefavAssistant.prototype.errorHandler = function(transaction, error) 
    { 
        console.log('Error was '+error.message+' (Code '+error.code+')'); 
        return true;
    }
    savefav-scene.html

    Code:
    <div class="palm-group">
    	<div class="palm-group-title" style="text-align:center">List Fun</div>
    		<div class="palm-list" >
    		<div x-mojo-element="List" id="results_list"></div>
    	</div>
    	<div x-mojo-element="Button" id="pop_button" class="buttonClass" name="buttonName"></div>
    </div>
    mainListTemplate-scene.html
    Code:
    <div class="palm-list">#{-listElements}</div>
    mainRowTemplate-scene.html
    Code:
     <div class="palm-row" x-mojo-touch-feedback="delayed">  
    <div class="palm-row-wrapper">  
    <div id="itemTitle" class="title truncating-text">#{text}</div>  
    <div id="itemTitle" class="title truncating-text">#{title}</div>  
    </div>  
    </div>
    Please help me sort this issue

    Thanks in advance
Page 4 of 4 FirstFirst 1234

Posting Permissions