HOWTO: Redeploy an application

$ palm-install -r com.mystuff.hello ; palm-package HelloWorld && \
palm-install com.mystuff.hello_1.0.0_all.ipk && palm-launch com.mystuff.hello

HOWTO: Enable logging in the emulator

$ palm-log -d tcp -f

More information.

HOWTO: Fake/simulate events results such as phone calls on the emulator?

To simulate simulate events like phone calls, as well as information like GPS fixes, see the documentation on luna-send.

HOWTO: Install an application on the phone (not emulator)

  1. Enable developer mode.
  2. Use the normal palm-* tools, but specify a "device" of usb. e.g. palm-install -d usb com.aroundere.client_0.0.1_all.ipk.

HOWTO: Disable developer mode

Follow the instructions in enable developer mode, but move the "Developer Mode" slide to Off instead of On.

FAQ: Keyboard shortcuts for the emulator

Key Description

ALT (Windows and Linux) or OPTION (Mac) Option key.

END Opens and closes the launcher.

ESC Performs the back gesture (or swipe back).

Home Minimizes and maximizes the card.

LEFT/RIGHT ARROW Switches the application left or right in the Card view.

Sym (symbol) key This key is not yet implemented.

Source.

HOWTO: Load an application onto the emulator

To remove an existing application, package up a new version, install it, and launch it, do:

palm-install -r org.beebo.lonelyplanet ; palm-package LonelyPlanet/ && palm-install org.beebo.lonelyplanet_0.0.1_all.ipk && palm-launch org.beebo.lonelyplanet

palm-install -r com.mystuff.hello ; palm-package HelloWorld/ && palm-install com.mystuff.hello_1.0.0_all.ipk && palm-launch com.mystuff.hello

TIP: Overview

This is a pretty decent overview of how an application is put together, including stages and scenes:

http://developer.palm.com/index.php?option=com_content&view=article&id=1648

FAQ: What is sources.json used for?

sources.json is used by the loader to figure out what JS files to load, and when. (i.e. as an alternative to listing all your JS files in <script> elements at the top of index.html.) An example sources.json looks like this:

[
    { "source": "app/assistants/app-assistant.js" },
    { "source": "app/assistants/stage-assistant.js" },
    { "source": "app/assistants/first-assistant.js", "scenes": "first" },
    { "source": "app/assistants/second-assistant.js", "scenes": "second" }
]

There are a few rules:

More information.

FAQ: What's the application structure? What files and directories are mandatory?

The only mandatory files and directories are the appinfo.json and sources.json files that appear at the top level of the application, and the MyApp/views directory and everything within it.

More information.

FAQ: What's the launch/load/bootstrap process?

  1. The launch process looks in appinfo.json for a HTML file referenced by the main key, and loads this file. If there is no such key, index.html is used.
  2. Resources linked from the this file (such as CSS and JavaScript files) are loaded as usual. (For the bootstrap process to continue, this file must reference the JS file /usr/palm/frameworks/mojo/mojo.js in a script element; this loads the framework.)
  3. The bootstrap code in mojo.js reads sources.json, and loads JS files as appropriate. (All listed JS files are loaded, unless they contain a "scenes" property, in which case they're only loaded when the scene is pushed.)
  4. A Mojo.Controller.AppController is created. There is only ever one application controller per application.
  5. If an AppAssistant function/class exists at this point (i.e. because one of the JS files has defined it), it's instantiated (with the application controller passed in as the first argument).
    1. The AppAssistant's "setup" method is called (if it exists).
    2. The AppAssistant's "handleLaunch" method is called (if it exists).
  6. A Mojo.Controller.StageController is created. An application can have multiple stage controllers, and each stage controller manages a stack of scenes.
  7. If a StageAssistant function/class exists, it is instantiated. The stage controller is available as this.controller (though not in the constructor; the property is not set at that point).
    1. The stage assistant's "setup" method is called (if it exists). If this method pushes a scene (e.g. "first"), then an associated JS function (FirstAssistant) must exist. (Within the scene assistant, the property "controller" refers to a Mojo.Controller.SceneController.) Note that it's the object names that are important, not file names. A scene string (e.g. "first") tells to autoloader that e.g. the file first-assistant.js should be loaded, but simply loading the JS file does nothing by itself: this JS file must also define an object (e.g. FirstAssistant) for anything to happen.
  8. If there is no StageAssistant, or its setup method did not push a scene, a scene controller is created, then the "main" scene is pushed. ("Pushing" the main scene means that views/main/main-scene.html is loaded, and MainAssistant (which must exist) is instantiated.) As in the case with the "manual" scene push, within the MainAssistant, the property "controller" refers to a Mojo.Controller.SceneController.

This process is somewhat described on the Application Launch Cycle and Introduction to Applications pages of the WebOS documentation.

FAQ: How do I refer to images?

According to the application structure, images must be placed with the top-level images directory. From inside an assistant, use the path images/. From within CSS files, use the path url(../images/).

FAQ: Why aren't log messages being output?

For logging (via Mojo.Log.*) to work, you need a top-level framework_config.json file (i.e. at the same level as sources.json with the contents

{
    "logLevel": 99
}

HOWTO: Logging

IMPORTANT: make sure you have a top-level framework_config.json file (i.e. same level as sources.json) with the contents

{
    "logLevel": 99
}

to enable logging. Then, write to the log with:

Mojo.Log.info("I have ", 3, " eggs.");

More information.

View the log with:

$ palm-log -d tcp -f

Or:

$ novaterm
$ tail -f /var/log/messages

(The second will probably display more information (such as logging messages from luna-send), which may either be more or less helpful.)

More information.