Details about how to develop your first application through the official HP webOS tutorial (1)

Source: Internet
Author: User

BKJIA: This short tutorial will take you through your first HP webOS application. This tutorial will show you how to create a simple counter and calculate the click volume of the button, instead of simply displaying "Hello, World !". After this tutorial, you should be familiar with stages, scenes, assistants, and other important concepts.

I. Before the start

This tutorial helps you develop a simple webOS application to verify that your development tool works properly. This tutorial assumes that you are familiar with HTML and JavaScript. If you are just learning HTML and JavaScript, we have collected some links related to Web development, hoping to help you.

Before starting your first webOS application, install the HP webOS SDK. The webOS SDK installs several command line tools for creating, encapsulating, installing, and debugging applications. The installation package also tells you how to download the VirtualBox of Oracle, which is a virtual machine environment. Install the Virtual Machine file for the SDK because you need to simulate the webOS environment on your desktop.

Familiarize yourself with the simulator and make sure you know how to start the application using the simulator. You can click the arrow icon in the lower right corner of the webOS main interface to start the simulator ). The simulator runs like a real Palm device, but you need to input it on your computer keyboard, use your mouse to control the action, and use the Esc key to simulate the return key.

You can use the HP command line tool to develop an application, or use your favorite text editor and Web development tools. Use the webOS plug-in of Eclipse to simplify the process of debugging, encapsulating, installing, and running webOS applications. For more information, see the Eclipse website.

2. Application directory

The webOS application directory has a specific structure. These guides will show you how to use the webOS SDK command line tool to set the application directory structure and the initial settings of the files required to create an application.

Note: If you are using Eclipse with the webOS SDK plug-in, select "file"> "new"> "Mojo application ". Enter "HelloWorld" as the project name and title, and accept the default value in other options. Click "finish" to create the application framework .)

1. Set the directory structure of the application

1) Open a command prompt window and create a development application workspace directory, for example, app_dir ).

2) In the workspace directory, enter the following single quotation marks in the double quotation marks ):

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

2. Let's take a look at the content of the new HelloWorld Folder:

1) application Folder: contains the assistants, models, and views files that constitute the application. After this tutorial, you will add the file to this directory.

2) image Folder: contains all the images used by the application.

3) style sheet Folder: contains the stacked style sheet file of the application.

4) appinfo. json: The information file of the application.

5)icon.png: the icon displayed by the application on the simulator or device.

62.16index.html: The homepage file when the application opens.

7) sources. json: list of source files for each scene.

For more information about the application directory structure, see application structure.

3. Application Information

The appinfo. json file provides information about how the SDK framework encapsulates and runs applications. Let's take a look at the content of appinfo. json:

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

Pay attention to the ID and supplier parameters. This will be helpful when you create signed applications on their respective devices.

Iv. set Stage

Stage is a platform built on the application user interface. Stage usually corresponds to a separate tab or application window. The simplest application only has a stage, which is included in the index.html file. The application allows you to perform multiple operations at the same time, which may require multiple stages. For example, the email application may display an inbox on Stage, but the second step creates a new email. There is no Stage for notifications and background applications.

2.to view the content of index.html:

 
  1. <!DOCTYPE html> 
  2.  
  3.  
  4.  
  5.     <title>Hello World</title> 
  6.  
  7.     <script src="/usr/palm/frameworks/mojo/mojo.js" 
  8.  
  9.          type="text/javascript" x-mojo-version="1"></script> 
  10.  
  11.      <!-- application stylesheet should come in after the one loaded by the framework --> 
  12.  
  13.     <link href="/stylesheets/helloworld.css" media="screen" rel="stylesheet" type="text/css"> 
  14.  
  15.  

Please note that index.html is a standard HTML page. The <script> tag generates the SDK framework required by the webOS application. Now it is time to test the running effect of your application in the simulator, although it does not play much role yet.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.