在 webOS 应用程序中提交和存储数据?
我正在为 webOS 构建一个笔记应用程序,我想知道如何存储 HTML 输入表单中的数据。因此,如果用户输入文本或图像注释,我将它们存储在应用程序中的何处以及如何存储,以便它保留在那里?
I'm building a note taking application for webOS and I was wondering how you would store the 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您似乎误解了 WebOS 工作原理的一些基础知识。您很少会直接与表单输入进行交互。相反,您最常使用小部件,例如 TextField 或 富文本编辑。典型的流程是在 HTML 中创建 TextField div,然后在场景助手
setup
方法中对其进行初始化,并在Mojo.Event.propertyChange
中添加监听器>activate 方法(在deactivate
中调用相应的stopListening
)。当然也可以使用自定义表单输入、contentEditable div 等,但小部件通常是最好的入门方式(如果小部件不能完成您想要的所有操作,您可以稍后切换到自定义的内容) )。
否则,XRAY Enabler 的答案是正确的。由于您无法确定用户将输入的注释的大小或数量,因此您将需要使用 Depot 或 HTML5 SQLite 数据库。 Depot 在某种程度上更容易,但你必须一次获取所有笔记(这样它们就会全部存在于内存中)。 SQLite 数据库更难使用,但可以让您在处理数据的方式上有很大的灵活性。如果您决定使用 HTML5 数据库,您可能会发现我的 WebOS 数据库类 很有用;它使您远离一些更令人发指的数据库连接代码,提供用于生成基本 SQL 查询的帮助程序,并提供以 JSON 定义数据库模式的能力(我编码并将其用于我自己的笔记应用程序,TapNote)。
如果您参与了 WebOS 抢先体验计划,如果您决定主要针对 Palm 的未来设备而不是当前可用的设备,还可以使用 WebOS 2.0 或 Enyo 的其他存储方法。
祝你好运!
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 toMojo.Event.propertyChange
in youractivate
method (with a correspondingstopListening
call indeactivate
).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!
来自: http://developer.palm.com/index .php?option=com_content&view=article&id=1734
Mojo 支持三种存储数据的方法:
对于复杂的情况,我会使用 HTML5 数据库对象否则 Depot 的键/值对应该没问题。
From: http://developer.palm.com/index.php?option=com_content&view=article&id=1734
Mojo supports three methods for storing data:
For a complex situation I would go with the HTML5 database object otherwise key/value pairs of Depot should do fine.