Results 1 to 6 of 6
  1. dr3wster's Avatar
    Posts
    92 Posts
    Global Posts
    96 Global Posts
       #1  
    Hey Everyone!

    I'm a beginner programmer, but am looking at coding a very simple program for my Palm Pre..

    I have a number of XML files that are exported from Access 2007.

    I want to create an app that essentially takes the XML files (eg. release dates for products) and then calculates the number of days to release, and then sorts them in order.


    I want the program to consist of:
    1) home screen with maybe a login / passcode entry
    2) 3 separate pages for each of the three XML files


    Very basic. But, I dont know where to start! I have already looked at: Tutorials webOS Getting Started - WebOS Internals

    So I know the three or so components a WebOS app needs (JSON file, .html and a .PNG file).


    Any pointers??

    Thanks!
  2. #2  
    I am looking for the same info.. any help would be appreciated...
  3. #3  
    You use json to transfer data instead of xml for the pre. They are very similar actually. I hated jumping into json also, but now I don't mind it.
  4. #4  
    JSON is the preferred format, and really is quite superior. But for XML, it's the same as in Javascript...

    But here is a sample from FlashCards:

    Code:
    var that = this;
    var url = "http://www.domain.com/somefile.xml";
    var request = new Ajax.Request(url, {
    	method: 'get',
    	evalJS: false,
    	evalJSON: false,
    	onComplete: function(transport){
    		that.loadSuccess(transport).bind(that);
    	},
    	onFailure: function(transport){
    		that.loadFailure(transport).bind(that);
    	}
    });
    And then your success and failure handlers (and a handler to loop the items):
    Code:
    MysetsAssistant.prototype.loadSuccess = function(transport) {
    	if (transport.responseXML === null && transport.responseText !== null) {
    		transport.responseXML = new DOMParser().parseFromString(transport.responseText, 'text/xml');
    	}
    
    	var xml = transport.responseXML;
    	var statuscode = xml.getElementsByTagName("statuscode")[0].childNodes[0].nodeValue;
    	var msg = xml.getElementsByTagName("msg")[0].childNodes[0].nodeValue;
    
    	if (statuscode!="-1"){
    		//--> Error processing on server, display error message
    		Mojo.Controller.errorDialog(msg);
    	}else{
    		var results = xml.getElementsByTagName("item");
    		var numResults = results.length;
    
    		//--> Start our recursive/defer loop to add items
    		this.loadItems(0, results, this);
    	}
    }
    MysetsAssistant.prototype.loadItems = function(i, results, that) {
    	var vID = results[i].getAttribute("id");
    	var vCount = results[i].getAttribute("count");
    	var vName = results[i].getAttribute("name");
    
    	
    	//--> Push this record to the list array
    	that.results.push({id:vID, count:vCount, name:vName});
    
    	if (i >= results.length-1){
    		that.controller.modelChanged(that.listModel);
    		$("loadSpinner").mojo.stop(); //spinnaz no mo!
    	}else{
    		if (i < results.length){
    			that.loadItems.defer(i+1, results, that)
    		}
    	}
    }
    MysetsAssistant.prototype.loadFailure = function(transport) {
    	Mojo.Controller.errorDialog("There was an error accessing the data source. Please try again later.");
    }
    You will notice the 'loadItems' function. This is required when processing fairly large sets of data, as the XML parser is kinda slow and will lock up the UI, which will then timeout. Using .defer releases the UI and allows the processing to continue. Enjoy!
  5. #5  
    Err... reread post and you need basics, not XML handling... sorry
  6. #6  
    lol @ spinnaz no mo

Posting Permissions