开发者

rails best way to receive xml data from flex application

Can anybody give me any hints on that? I'm able to display xml content on my swf file but how can I send the changed xml file back to m开发者_运维知识库y rails Server?

Thanks in advance! Markus


RestfulX is by far the best way to do this with Rails :).

Check out their cool examples to get running, it takes 5 minutes. You can generate an application based on models (like Page/Post/Comment/Category...) that'll look like this:

rails best way to receive xml data from flex application


(source: github.com)

You basically run 3 commands and you have a full CMS. And, by default, everything happens via XML, but that's converted (serialized and deserialized) to and from xml, so you can use class objects in ActionScript. You can easily change that to AMF/JSON if you needed to, which is very powerful. Then you can customize everything from there: create a class (MyVideo), add properties (title, url, description, comments), manipulate them in ActionScript, then just do create/update/destroy/save/show, and it handles all the xml requests to/from Rails.

They've solved hardcore things like authentication and session management, file uploading, nested sets and list, etc, which you've probably already run into or will. It's very cool.

Everything works via REST (and CRUD operations), which Rails takes full advantage of. If you just want to use ruby (and not Rails), you can do that no problem. Or if you just wanted to use Flex and no backend, but still wanted to read/write XML without having to create a whole library to handle that, same thing; they handle it all.

You just do:

Rx.models.index(Project) (if you had a my.package.Project class), and it'd return:

<?xml version="1.0" encoding="UTF-8"?>
  <projects type="array">
    <project>
      <completed type="boolean">false</completed>
      <created_at type="datetime">2008/07/09 20:08:28</created_at>
      <end_date type="date">2008/07/09</end_date>
      <id type="integer">490909803</id>
      <name>Project4NameString</name>
      <notes>Project4NotesText</notes>
      <start_date type="date">2008/07/09</start_date>
      <updated_at type="datetime">2008/07/09 20:08:28</updated_at>
      <user_id type="integer">276171944</user_id>
  </project>
</projects>

Then if you wanted to save it (or delete it), you'd just do something like:


var projects:IList = Rx.models.index(Project);
var project:Project = projects.getItemAt(0); // first item in IList;
project.title = "My New Title!";
project.save();

// then later, maybe onClick for a Button with label "Delete Project"... project.delete();

This is by far the best library for XML processing. And they have a very active group which is a plus.

I saw you asked this question about writing xml via Flex. You'll run into lots of edge cases. Try out RestfulX, it's super sick.

Hope that helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜