开发者

Submit and store data in webOS application?

I'm building a note taking application for webOS and I was wondering how you would store t开发者_开发百科he data from an HTML input form. So if a user enters a text or image note, where and how would I store these in the app so it will stay there?


It seems that you are misunderstanding some of the basics for how WebOS works. You very rarely will interact directly with form inputs. Instead, you most often will be using a widget, such as the TextField or RichTextEdit. A typical flow is to create your TextField div in HTML, then initialize it in your scene assistant setup method, and add a listener to Mojo.Event.propertyChange in your activate method (with a corresponding stopListening call in deactivate).

It is also certainly possible to use custom form inputs, contentEditable divs, and so forth, but the widgets are usually the best way to get started (then if the widget doesn't do everything you want, you can switch over to something custom later).

Otherwise, XRAY Enabler's answer is correct. Since you cannot determine the size or quantity of notes the user will enter, you are going to want to use Depot or the HTML5 SQLite database. Depot is easier to some extent, but you have to fetch all notes at once (so they'll all be living in memory). SQLite database is more difficult to work with, but allows you a lot of flexibility in how you handle the data. If you decide to use HTML5 database, you might find my WebOS database class useful; it abstracts you away from some of the more heinous database connection code, provides helpers for generating basic SQL queries, and offers the ability to define your database schema in JSON (I coded and use it for my own note-taking app, TapNote).

If you are part of the WebOS early access program, there are also other storage methods that you can use with WebOS 2.0 or Enyo, if you decide you want to primarily target Palm's future devices instead of their currently available devices.

Good luck!


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

Mojo supports three methods for storing data:

  • Mojo.Model.Cookie
  • Mojo.Depot
  • HTML 5 database object

For a complex situation I would go with the HTML5 database object otherwise key/value pairs of Depot should do fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜