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
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)
- Enable developer mode.
- Use the normal
palm-*tools, but specify a "device" ofusb. 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.
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:
- If the application uses an
app-assistant.js, it should be the first JS file listed. - If an object includes a "scenes" property, then it is only loaded when the scene is pushed. If there is no "scenes" property, the associated JS file is loaded when the application is launched. (However it is then not available in a particular scene--if you want a JS file to be available in a particular scene, it must be explicitly listed.)
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.
FAQ: What's the launch/load/bootstrap process?
- The launch process looks in
appinfo.jsonfor a HTML file referenced by themainkey, and loads this file. If there is no such key,index.htmlis used. - 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.jsin ascriptelement; this loads the framework.) - The bootstrap code in
mojo.jsreadssources.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.) - A Mojo.Controller.AppController is created. There is only ever one application controller per application.
- If an
AppAssistantfunction/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).
- The AppAssistant's "setup" method is called (if it exists).
- The AppAssistant's "handleLaunch" method is called (if it exists).
- A Mojo.Controller.StageController is created. An application can have multiple stage controllers, and each stage controller manages a stack of scenes.
- If a
StageAssistantfunction/class exists, it is instantiated. The stage controller is available asthis.controller(though not in the constructor; the property is not set at that point).- 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 filefirst-assistant.jsshould 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.
- 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 (
- 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.htmlis loaded, andMainAssistant(which must exist) is instantiated.) As in the case with the "manual" scene push, within theMainAssistant, 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.");
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.)