构建第一个webOS应用程序--Hello World

这个简要的教程将教你创建你的第一个Palm® webOS™应用程序:一个简单的按钮点击计数器。学习完这个教程以后,你将对舞台(stages),场景(scenes),辅助器(assistants)以及其他一些重要的概念。

在你开始之前
在你开始你的第一个Palm® webOS™应用程序之前,请安装Palm® Mojo™ SDK。让你自己熟悉模拟器,并且知道怎么运行应用程序。这个教程将会帮助你建立一个简单的webOS应用程序,同时也能确信你的开发工具运行环境运行正常。
你只要使用Palm tools(palm工具)和你喜爱的文本编辑器或者web开发工具就能编写webOS应用程序。使用装有Palm插件的Eclipse就能简化调试,打包,安装和运行webOS应用程序。

应用程序的目录

webOS应用程序目录有特定的结构。如果你使用装有Palm SDK插件的Eclipse作为开发工具,你能通过“ File > New > Project and then choosing Mojo Application”创建webOS应用程序的目录结构。将项目命名为HelloWorld。或者,你可以使用命令工具palm-generate来建立这种目录结构:

1. 创建一个目录作为webOS应用程序的工作空间
2. 在这个工作空间目录下,键入下面一行:

      $ palm-generate -p "{title:'Hello World', id:com.mystuff.hello, version:'1.0.0'}" HelloWorld

看一下这个新建的HelloWorld目录下的内容:
    * app — contains the assistants, models, and views that make up the application. Later in the tutorial, you will be adding files inside this directory.
    * appinfo.json — the Application Information file.
    * icon.png — the image that the application presents in the Launcher on the emulator or device.
    * images — any other images the application uses.
    * index.html — the main stage on which the application's scenes will appear.
    * sources.json — a list of the source files for each scene.

For more information about the application directory structure, see Application Structure.
Application Information

The file appinfo.json provides information that the Mojo framework uses to package and run the application. Take a look at the contents of appinfo.json:

{
"id": "com.palm.developer",
"version": "1.0.0",
"vendor": "My Company",
"type": "web",
"main": "index.html",
"title": "Hello World",
"icon": "icon.png"
}



Notice the id and vendor parameters, which become useful when you are building signed applications to run on the device itself.
Setting the Stage

A stage is the platform on which you build the user interface for your application. A stage generally corresponds to a single card, or application window. Most simple applications have a single stage, contained in the file index.html. An application that lets the user perform more than one action concurrently might require more than one stage. For example, an email application might display the inbox on one stage, but launch a second stage to compose a new email message. Notification and background applications have no stages at all.

Take a look at the contents of index.html:


"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">


Hello There

你可能感兴趣的:(webos,application,palm,button,command,stylesheet)