webOS应用程序目录有特定的结构。如果你使用装有Palm SDK插件的Eclipse作为开发工具,你能通过“ File > New > Project and then choosing Mojo Application”创建webOS应用程序的目录结构。将项目命名为HelloWorld。或者,你可以使用命令工具palm-generate来建立这种目录结构:
看一下这个新建的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:
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
This text verifies your application is running.
To create a fully functional Palm application create a scene and remove this text from index.html. See the documentation on Palm Applications for more information on creating applications and scenes.
Notice that index.html is a standard xhtml page, with a tag that brings in the Mojo framework required for webOS applications. Although it won't do much yet, it's time to try running your application on the emulator.
Starting the Emulator
* Mac: In the Applications folder, double-click the Palm Emulator. * Windows: On the Desktop, double-click the Palm Emulator shortcut (or select Start > All Programs > Palm > SDK > Palm Emulator). * Linux: From the command line, type palm-emulator.
Running Applications on the Emulator
If you are using Eclipse with the Palm plug-in, you can run an application on the emulator by selecting Run > Run As > Palm Application. Eclipse automatically packages, installs, and launches the application.
Otherwise, run the application from the command line by using the palm tools included with the SDK.
To package and install a file on the emulator from the command line
1. Ensure that the emulator is running. 2. On the command line, navigate to your workspace directory, which contains all of your application directories. 3. Use the palm-package command to package the directory containing the application. Example:
$ palm-package HelloWorld
4. Use palm-install to install the resulting .ipk file on the emulator. Example:
$ palm-install com.mystuff.hello_1.0.0_all.ipk
Note: Installing a new version of an application does not remove the source files that are not present in the new version. During testing, it is useful to delete the old version of an application before installing a new version.
To delete the application on the emulator, use palm-install.
Example:
palm-install -r com.mystuff.hello
Launch an application from the console with:
$ palm-launch com.mystuff.hello
Close the application from the console with:
$ palm-launch -c com.yourdomain.yourapp
For more information about the emulator, see Emulator. Here is a screenshot of the emulator running the application. Making a Scene
A scene is a formatted screen for presenting information or a task to the user. Each scene has a view and an assistant. The view determines the layout and appearance of the scene. The assistant determines the behavior. Some scenes also have models, which supply data.
To create the first scene, type the following on the command line:
This command creates the view and the assistant for the first scene, and also adds a few lines to sources.json to correlate the assistants and scenes. Take a look at the following files:
* /app/views/first/first-scene.html — This is the view. * /app/assistants/first-assistant.js — This is the assistant. * sources.json — This file now includes JSON information that binds first-assistant.js to the first scene.
Edit the view (first-scene.html) to contain the following:
Header
0
In order to actually display the scene, you must tell the stage to push it. In the next section, you'll add that code to the stage assistant. The Stage Assistant
Like a view, the stage also has an assistant. In this simple application, the stage assistant's only task is to push the scene, making it visible. The stage assistant is a file called stage-assistant.js in the assistants directory. Edit stage-assistant.js to contain the following:
Notice that this stage assistant contains two functions:
* StageAssistant() is the constructor. * setup(), which is called when the stage is launched, pushes the first scene.
The application now has a stage and a scene. In order to make the application functional, it is time to write some code in the scene assistant. Script Writing
At last, it is time to breathe life into the application by adding code to the scene assistant for the first scene. To make the first scene's button functional, the application needs a button handler. This function updates the text each time the user taps the button. Add the following function to first-assistant.js:
FirstAssistant.prototype.handleButtonPress = function(event){ // increment the total and update the display this.total++; this.controller.get('count').update(this.total); }
Once you register the handler as a listener for Tap events on the button, the framework will call the handler every time the button is tapped. The handler must be bound to the scene assistant, so that when the framework calls the handler it has access to the scene and its DOM. Otherwise, the handler is bound by default to the calling object instead, which is not useful. This example demonstrates two steps:
* binding the handler to the scene assistant's scope, using bind(this) * registering the handler as a listener, using Mojo.Event.listen()
Edit the setup function to match the following example:
FirstAssistant.prototype.setup = function() {
// set the initial total and display it this.total=0; this.controller.get('count').update(this.total);
// a local object for button attributes this.buttonAttributes = {};
// a local object for button model this.buttonModel = { buttonLabel : 'TAP HERE', buttonClass : '', disabled : false };
// set up the button this.controller.setupWidget("MyButton", this.buttonAttributes, this.buttonModel); // bind the button to its handler Mojo.Event.listen(this.controller.get('MyButton'), Mojo.Event.tap, this.handleButtonPress.bind(this)); }
When you run the application, it shows how many times you have tapped the button.
Where to Go from here
* For more information about the structure of a webOS application, see Application Basics. * For more code samples, see Samples. * For information about webOS widgets, see Widgets.
XMLHttpRequest cannot load http://v.xxx.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342' is therefore not allowed access. test.html:1
1.什么是NoSQL数据库?NoSQL和RDBMS有什么区别?在哪些情况下使用和不使用NoSQL数据库?
NoSQL是非关系型数据库,NoSQL = Not Only SQL。
关系型数据库采用的结构化的数据,NoSQL采用的是键值对的方式存储数据。
在处理非结构化/半结构化的大数据时;在水平方向上进行扩展时;随时应对动态增加的数据项时可以优先考虑使用NoSQL数据库。
在考虑数据库的成熟
ClientWatchManager接口
//接口的唯一方法materialize用于确定那些Watcher需要被通知
//确定Watcher需要三方面的因素1.事件状态 2.事件类型 3.znode的path
public interface ClientWatchManager {
/**
* Return a set of watchers that should
解决mysql导入导出数据乱码问题方法:
1、进入mysql,通过如下命令查看数据库编码方式:
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------------------+
| Variable_name&nbs
Your love is also your weak point.
你的所爱同时也是你的弱点。
If anything in this life is certain, if history has taught us anything, it is
that you can kill anyone.
不顾家的人永远不可能成为一个真正的男人。 &
用phpMyAdmin导入mysql数据库时,我的10M的
数据库不能导入,提示mysql数据库最大只能导入2M。
phpMyAdmin数据库导入出错: You probably tried to upload too large file. Please refer to documentation for ways to workaround this limit.
1、create database school 创建数据库school
2、drop database school 删除数据库school
3、use school 连接到school数据库,使其成为当前数据库
4、create table class(classID int primary key identity not null)
创建一个名为class的表,其有一