Results 1 to 17 of 17
  1. hduty's Avatar
    Posts
    69 Posts
    Global Posts
    84 Global Posts
       #1  
    Looking at the API for each widget there are usually several methods for each widget (e.g. 'focusItem()' in the List widget). But how do you get a reference to the widget inside the jsjsjs $code$ $in$ $order$ $to$ $invoke$ $these$ $methods$?

    I've tried several things, including 'this.controller.get('listID')', but to no avail.
    Any help would be much appreciated.
    Palm Vx (a classic) -> Palm m505 (*yawn*) -> Dell Axim (slooow...!) -> Palm TE (great) -> Qtek 9090 (great idea, lousy platform) -> Nokia 6630 (a toy) -> iMate SP3i (not bad) -> Nokia 9300 (can't sync notes!!) -> Treo 650 (awesome!) -> iPaq hw6915 (almost perfect) -> Nokia E51 (un/impressive) -> HTC Touch Enhanced (nice!) -> Samsung i780 (mousepad woes) -> HTC s740 (very good) -> Nokia E72 (RAM starved) -> HTC HD mini (...) -> Palm Pre 2
  2. #2  
    well, assume you have some element like a button. so your html says
    <div id="button1" class=palm-button></div>

    and you want to invoke some method of that button

    So, $('button1').methodname(parameters);

    like that.
    Last edited by rboatright; 07/20/2009 at 07:22 AM. Reason: left out '
  3. hduty's Avatar
    Posts
    69 Posts
    Global Posts
    84 Global Posts
       #3  
    Thanks for the quick reply.

    I've tried that, on several components, but I can't get it to work, not even a simple thing such as $('idTextfield').setText('foo').

    When I log the properties/methods of the widget, such as
    Mojo.Log.info( $('idTextfield').setText )
    I get 'undefined', meaning that the property does not exist on that object.

    I'm I missing something here?
    Palm Vx (a classic) -> Palm m505 (*yawn*) -> Dell Axim (slooow...!) -> Palm TE (great) -> Qtek 9090 (great idea, lousy platform) -> Nokia 6630 (a toy) -> iMate SP3i (not bad) -> Nokia 9300 (can't sync notes!!) -> Treo 650 (awesome!) -> iPaq hw6915 (almost perfect) -> Nokia E51 (un/impressive) -> HTC Touch Enhanced (nice!) -> Samsung i780 (mousepad woes) -> HTC s740 (very good) -> Nokia E72 (RAM starved) -> HTC HD mini (...) -> Palm Pre 2
  4. hduty's Avatar
    Posts
    69 Posts
    Global Posts
    84 Global Posts
       #4  
    OK, so I digged around a little and discovered that one way to do it is:
    $('elementID').mojo.setText('abc')

    According to the same source it seems it only works in the emulator, and it fails on the device.
    Palm Vx (a classic) -> Palm m505 (*yawn*) -> Dell Axim (slooow...!) -> Palm TE (great) -> Qtek 9090 (great idea, lousy platform) -> Nokia 6630 (a toy) -> iMate SP3i (not bad) -> Nokia 9300 (can't sync notes!!) -> Treo 650 (awesome!) -> iPaq hw6915 (almost perfect) -> Nokia E51 (un/impressive) -> HTC Touch Enhanced (nice!) -> Samsung i780 (mousepad woes) -> HTC s740 (very good) -> Nokia E72 (RAM starved) -> HTC HD mini (...) -> Palm Pre 2
  5. #5  
    It works fine on the device.

    But every different widget has different methods and properties.

    and you need to distinguish between a method and a property.

    For example, a button has two methods. activate() and deactivate.
    It has a model, and attributes.

    so, if you were interested in the label of a button you could use
    $('button_div_id').model.label

    and if you wanted to set the label, you could write

    $('button_div_id').model.label = "some text"

    Palm Mojo Framework - Mojo.Widget

    is your friend. Read it. Read it again. Print it out and keep a copy by your computer.
  6. #6  
    Oh. and refering back to the first post...
    Palm Mojo Framework - Mojo.Widget says that setText is a deprecated method, and will be dropped, don't use it, and it's a method ONLY of textfields and password fields.....
  7. hduty's Avatar
    Posts
    69 Posts
    Global Posts
    84 Global Posts
       #7  
    setText() was just an example, but thanks anyway.

    I'm aware of the difference between a method and a property, but if you "call" a method as if it were a property you know at least that the method exists, which I was trying to prove.

    Again, thanks.
    Palm Vx (a classic) -> Palm m505 (*yawn*) -> Dell Axim (slooow...!) -> Palm TE (great) -> Qtek 9090 (great idea, lousy platform) -> Nokia 6630 (a toy) -> iMate SP3i (not bad) -> Nokia 9300 (can't sync notes!!) -> Treo 650 (awesome!) -> iPaq hw6915 (almost perfect) -> Nokia E51 (un/impressive) -> HTC Touch Enhanced (nice!) -> Samsung i780 (mousepad woes) -> HTC s740 (very good) -> Nokia E72 (RAM starved) -> HTC HD mini (...) -> Palm Pre 2
  8. #8  
    Quote Originally Posted by rboatright View Post
    Palm Mojo Framework - Mojo.Widget

    is your friend. Read it. Read it again. Print it out and keep a copy by your computer.
    rboatright,

    <evil vilin voice>AH HA!!</evil vilin voice> ! I had been thinking last night and this morning that you have a very firm grasp of widgets. I figured you must be reading the online documents or something and then this.

    This reference really helped me alot with my radio buttons last night. I have been having a really hard time trying to track down the code in the sameples code and this is a much better way to learn things.

    Kudos!
  9. #9  
    I am -very- good at looking things up. It is my great strength. Well, that and explaining things in english. Well, looking things up, and explaining things in english and spelling poorly. Well,.....

    (sorry. Monty Python fan)
  10. #10  
    Just as an FYI, if you plan on refactoring your app to use an app assistant, you will have to use this.controller.get('myWidgetId'), which does the same thing.
    Developer of:

    -------------------------------------
    Discuss my apps in my developer forum
  11. hduty's Avatar
    Posts
    69 Posts
    Global Posts
    84 Global Posts
       #11  
    Quote Originally Posted by Kev1000000 View Post
    Just as an FYI, if you plan on refactoring your app to use an app assistant, you will have to use this.controller.get('myWidgetId'), which does the same thing.
    Could please expand on that?
    What do you mean by 'app assistant', and as opposed to what?
    Palm Vx (a classic) -> Palm m505 (*yawn*) -> Dell Axim (slooow...!) -> Palm TE (great) -> Qtek 9090 (great idea, lousy platform) -> Nokia 6630 (a toy) -> iMate SP3i (not bad) -> Nokia 9300 (can't sync notes!!) -> Treo 650 (awesome!) -> iPaq hw6915 (almost perfect) -> Nokia E51 (un/impressive) -> HTC Touch Enhanced (nice!) -> Samsung i780 (mousepad woes) -> HTC s740 (very good) -> Nokia E72 (RAM starved) -> HTC HD mini (...) -> Palm Pre 2
  12. #12  
    Quote Originally Posted by hduty View Post
    Could please expand on that?
    What do you mean by 'app assistant', and as opposed to what?
    If you have more than one stage in your application (new cards, dashboard stages, etc), you have to use an app-assistant instead of only having one stage assistant.

    The app-assistant can spawn off new stages, and also control global service requests. However, when you use an app-assistant, you can no longer use prototype's $() macros. You have to use this.controller.get().
    Developer of:

    -------------------------------------
    Discuss my apps in my developer forum
  13. #13  
    Hey Kev, could you please elaborate a little on the app-assistant? I've had multistage apps where I just have a stage-assistant. All my stage-assistant does is call the first scene when the app is launched and that is all.

    Are there any benefits to it?

    *reads Palm's official documentation*
  14. hduty's Avatar
    Posts
    69 Posts
    Global Posts
    84 Global Posts
       #14  
    I still don't know enough about cards, stages, etc to grasp your answer fully, but I roughly understand it.

    Couldn't one always use this.controller.get() then, or is it discouraged for some reason? In all the sample code I've seen they use this.controller.get(), e.g. when they setup the event handlers.

    Thanks
    Palm Vx (a classic) -> Palm m505 (*yawn*) -> Dell Axim (slooow...!) -> Palm TE (great) -> Qtek 9090 (great idea, lousy platform) -> Nokia 6630 (a toy) -> iMate SP3i (not bad) -> Nokia 9300 (can't sync notes!!) -> Treo 650 (awesome!) -> iPaq hw6915 (almost perfect) -> Nokia E51 (un/impressive) -> HTC Touch Enhanced (nice!) -> Samsung i780 (mousepad woes) -> HTC s740 (very good) -> Nokia E72 (RAM starved) -> HTC HD mini (...) -> Palm Pre 2
  15. #15  
    Quote Originally Posted by SirataXero View Post
    Hey Kev, could you please elaborate a little on the app-assistant? I've had multistage apps where I just have a stage-assistant. All my stage-assistant does is call the first scene when the app is launched and that is all.

    Are there any benefits to it?

    *reads Palm's official documentation*
    App Assistants get called with launchParameters to your app, and launch with no windows or stages. You have to create your stages and create your scenes inside of the stage. It's a little more work, but better in the end if you plan on using dashboard stages or other stages.

    What I did was create an app-assistant.jsjsjs $file$ $and$ $put$ $that$ $at$ $the$ $TOP$ $of$ $the$ $sources$.$json$ $file$.

    Then, in the app-assistant file, i have...

    Code:
    AppAssistant.prototype.handleLaunch = function (launchParams) { 
        var cardStageProxy = this.controller.getStageProxy(MainStageName); 
        var cardStageController = this.controller.getStageController(MainStageName); 
        var appController = Mojo.Controller.getAppController(); 
        var dashboardStage = this.controller.getStageProxy(DashboardStageName); 
        if (!launchParams)  { 
            // FIRST LAUNCH 
            // Look for an existing main stage by name. 
            if (cardStageController) { 
                // If it exists, just bring it to the front by focusing its window. 
                cardStageController.popScenesTo("home"); 
                cardStageController.window.focus(); 
            } else { 
                // Create a callback function to set up the new main stage 
                // once it is done loading. It is passed the new stage controller 
                // as the first parameter. 
                var pushMainScene = function(stageController) { 
                    stageController.pushScene('home', feedList); 
                }; 
                var stageArguments = {name: MainStageName, lightweight: true}; 
                this.controller.createStageWithCallback(stageArguments, 
                    pushMainScene.bind(this), "card"); 
            } 
        }
    	 else  { 
            switch (launchParams.action) { 
            // NOTIFICATION 
            case 'notification'  : 
                if (cardStageController) { 
                    // If it exists, bring the feedList scene to the front by 
                    //   popping any other scenes and focusing the stage window. 
                    cardStageController.popScenesTo("home", feedList[0]); 
                    cardStageController.window.focus(); 
                } else { 
                    // Create a callback function to set up the new main stage 
                    // once it is done loading. It is passed the new stage controller 
                    // as the first parameter. 						
                    var pushMainScene2 = function(stageController) { 
                        stageController.pushScene('detaildealview', launchParams.params.dealSiteIndex, launchParams.params.storyNum); 
                    }; 
                    Mojo.Log.info("......... News - Create Main Stage"); 
                    var stageArguments2 = {name: MainStageName, lightweight: true}; 
                    this.controller.createStageWithCallback(stageArguments2, 
                       pushMainScene2.bind(this), "card"); 
                } 
            break; 
            } 
        }
    };
    Developer of:

    -------------------------------------
    Discuss my apps in my developer forum
  16. #16  
    Hmm... without actually going through line by line of the code you posted, it seems things like "First Launch Welcome Screens" and/or splash screens are possible with an app-assistant and just seem to be possible via "work-arounds" on a stage-assistant. So a stage-assistant is essentially a very simplified, stripped or streamlined version of an app-assistant?

    I think i'm slowly starting to see why an app-assistant would be better.

    However, including one line of code in the stage-assistant vs. the entire code you just put up for an app-assistant seems to make me want to stick with a stage-assistant for now...

    haha.
  17. rmbwebs's Avatar
    Posts
    129 Posts
    Global Posts
    145 Global Posts
    #17  
    A "stage" roughly translates to a "card". If you want an app that uses multiple cards you need an app assistant to manage the different stages. An example would be the email application which opens a new stage for composing an email.

Posting Permissions