This document provides an overview of how to build applications using Flex 3 and Rails 2 together. It includes sections on Flex 3, Rails 2, how they can be used together, and building a simple Flex and Rails application using XML over HTTPService. Rails provides a standard MVC architecture and handles communication between the web server and database. Flex 3 applications are written in MXML and ActionScript files and compiled into a SWF to run in a web browser using Flash. The SWF can interact with the containing web page and server.
Ruby on Rails, often simply referred to as Rails, is an open-source web application framework written in Ruby. It follows the Model-View-Controller (MVC) architectural pattern, which separates an application into three interconnected components to promote code Ruby Rails Web Development organization and maintainability. Ruby on Rails has gained popularity for its focus on developer productivity and its convention-over-configuration philosophy, which significantly reduces the need for boilerplate code and configuration.
Ruby on Rails, often simply referred to as Rails, is an open-source web application framework written in Ruby. It follows the Model-View-Controller (MVC) architectural pattern, which separates an application into three interconnected components to promote code Ruby Rails Web Development organization and maintainability. Ruby on Rails has gained popularity for its focus on developer productivity and its convention-over-configuration philosophy, which significantly reduces the need for boilerplate code and configuration.
Ruby on Rails, often simply referred to as Rails, is a powerful and popular web
development framework that has transformed the way we build web
applications.
I prepared this presentation to introduce Ruby on Rails to
a group of students at Università di Catania.
It is not enough to get a good grasp of Rails, the
presentation in fact was supported by live coding, where
I started created a Phrasalbook (no more blog engine
please :) )
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
Flexiblerails
1. Subscribe Now for FREE! refcardz.com
tech facts at your fingertips
CONTENTS INCLUDE:
n
About Flexible Rails
Flexible Rails: Flex 3 on Rails 2
n
Overview of Rails 2
n
Overview of Flex 3
n
Flex 3 and Rails 2 Together
n
Building a Flex + Rails
Application By Peter Armstrong
n
Hot Tips and more...
The typical sequence is as follows:
ABOUT FLEXIBLE RAILS
1. A user visits a particular URL in their web browser (makes
Simply put, Flex is the most productive way to build the UI an HTTP request).
of Rich Internet Applications, and Rails is a very productive 2. This request goes over the Internet to the web server in
way to rapidly build a database-backed CRUD application, which Rails is running.
thanks to ActiveRecord (the ORM layer of Rails) and thanks 3. That web server passes the request to the routing code in
to the principles of Convention Over Configuration and Rails, which triggers the appropriate controller method call
DRY (Don’t Repeat Yourself). This refcard shows you how to based on the routes defined in configroutes.rb.
get started. It provides an overview of Flex and Rails, how
4. The controller method is called. It communicates with
they can be used together and then building a simple Flex
various ActiveRecord models (which are persisted to and
+ Rails application using XML over HTTPService to have
retrieved from a database of your choosing). The controller
the Flex client talk to a RESTful Rails server. Since we’ll use
method can then do one of two things:
RESTful Rails controllers, the Rails controller methods will
also support the traditional HTML views. 1. Set some instance variables and allow a view
template (a specially named .html.erb file, for
example) to be used to produce HTML, XML, or
www.dzone.com
OvERvIEw OF RAILS 2 JavaScript, which is sent to the browser.
2. Bypass the view mechanism and do rendering
Rails provides a standard three-tier architecture (presentation tier,
directly via a call to the render method. This method
model tier, persistence tier) as well as a Model-View-Controller
can produce plain text (render :text => quot;fooquot;), XML
(MVC) architecture. As shown in Figure 1, Rails takes care of
(render :text => @task), and so on.
everything between the web server and the database.
OvERvIEw OF FLEX 3
Web Browser Client
In Flex 3, you write code in MXML (XML files with a .mxml
extension; M for Macromedia) and ActionScript (text files with
HTTP Request HTML
http://www.pomodo.com/tasks/list XML Internet a .as extension) files and compile them into a SWF file, which
JavaScript runs in the Flash player. This SWF is referenced by an HTML
render :text, render :xml file, so that when a user with a modern web browser loads
the HTML file, it plays the Flash movie (prompting the user
Flexible Rails: Flex 3 on Rails 2
Rails to download Flash 9 if it’s not present). The SWF contained in
Presentation the web page can interact with the web page it’s contained
ActionController::Routing::Routes Tier in and with the server it was sent from.
ActionController ActionView
(Controller) (View)
Get More Refcardz
(They’re free!)
ActiveRecord
(Model) Model Tier n Authoritative content
n Designed for developers
n Written by top experts
n Latest tools & technologies
MySQL Persistence
n Hot tips & examples
PostgreSQL Tier n Bonus content online
Oracle
DB2, etc. n New issue every 1-2 weeks
Figure 1: Rails provides a standard three-tier architecture (presenta- Subscribe Now for FREE!
tion tier, model tier, persistence tier) as well as a Model-View-Controller Refcardz.com
architecture.
DZone, Inc. | www.dzone.com
2. 2
Flexible Rails: Flex 3 on Rails 2
tech facts at your fingertips
FLEX 3 AND RAILS 2 TOgEThER INSTALLINg EvERyThINg
Flex and Rails can be used together with XML over HTTPService To get started, various software packages need to be installed.
or with Action Message Format. The XML over HTTPService The full instructions can be found in chapter 2 of Flexible Rails
approach is shown in Figure 2 below. (Manning Publications). Here’s what is needed:
1. Ruby 1.8.6
Web Browser with Flash Player 9 2. RubyGems 1.0.0 (or higher)
Web Client 3. Rails. 2.0.2 (or higher)
Flex app (SWF)
Page
4. Flex Builder 3
render :text, render :xml 5. SQLite
XML Internet 6. The sqlite3 gem, installed by running this command:
HTTP Request
http://www.pomodo.com/tasks/list C:>gem install sqlite3-ruby
Presentation Resource URL Notes
Rails Tier
RubyonRails http://rubyonrails.org/down
ActionController::Routing::Routes HiveLogic http://hivelogic.com/articles/2008/02/
ruby-rails-leopard
SQLite http://www.sqlite.org/download.html On Windows, download
ActionController ActionView
sqlite-3_5_5.zip or higher
(Controller) (View) and sqlitedll-3_5_5.zip or
higher, and unzip both of
them into C:WINDOWS
Model Tier system32
ActiveRecord
(Model)
BUILDINg A FLEX + RAILS APPLICATION
Persistence
Tier The world doesn’t need Yet Another Todo List, but let’s build
one. Unlike most Rails tutorials, we will assume you are using
Windows. (Rails has “crossed the chasm”, so this is now becom-
ing the correct assumption.)
MySQL , PostgreSQL Open a command prompt or Terminal window and run the fol-
Oracle, DB2, etc.
lowing commands:
Figure 2. C:>rails todo
This installs the SQLite3 gem and then creates a new Rails appli-
The AMF waters are a bit muddier: there are currently three
cation which by default uses the SQLite database. (The default
ways that Flex can talk to Rails using AMF and RemoteObject:
in Rails 2.0.1 and below was MySQL.)
n
RubyAMF Next, create a couple of directories:
n
WebORB for Rails C:>cd todo
n
BlazeDS (with Rails running on JRuby). C:todo>mkdir appflex
C:todo>mkdir publicbin
Next, switch to Flex Builder 3 and create the new Flex project:
Flash 9? Are you kidding me?
1. Do File > New > Flex Project...
FYI The reference to Flash 9 earlier may have set off 2. Choose to create a new project named Todo in c:todo
alarm bells in your head: “Isn’t Flash 9 somewhat
3. Leave its type set to “Web application” and its “Application
new? How many people will be able to run my app?” Well, server type” set to None and click Next
while not everyone has Flash 9, most do: according to http:// 4. Set the Output folder of the Flex project to publicbin and
www.adobe.com/products/player_census/flashplayer/ click Next
version_ penetration.html Flash 9 has reached near ubiquity: 5. Set the “Main source folder” to appflex, leave the “Main
application file” as Todo.mxml and set the output folder
97.3% in US/Canada, 96.5% in Europe and 98.0% in Japan.
to http://localhost:3000/bin and click Finish. Your new Flex
This is better than Windows. project will be created. (Note that public isn’t part of the
path since it’s the root; 3000 is the default port for the server).
DZone, Inc. | www.dzone.com
3. 3
Flexible Rails: Flex 3 on Rails 2
tech facts at your fingertips
The TasksController (in appcontrollerstasks_controller.rb)
We are using appflex as the root of all our looks like this:
Hot Flex code—in larger team environments it’s
class TasksController < ApplicationController
Tip advisable to create a Flex project as a sibling
# GET /tasks
of the Rails app (say, c:todoclient) and set
its output folder to go inside c:todopublic # GET /tasks.xml
bin. This way, different team members can use def index
different IDEs for the client and server projects: @tasks = Task.find(:all)
for example, Aptana and Flex Builder are both respond_to do |format|
Eclipse-based, and interesting things can format.html # index.html.erb
happen when you nest projects. format.xml { render :xml => @tasks }
end
Building a Flex + Rails Application, continued end
Next, let’s create a new Task resource using the now-RESTful # GET /tasks/1
scaffold command. # GET /tasks/1.xml
C:todo>ruby scriptgenerate scaffold Task name:string def show
Here we are creating a Task that has a name attribute, which @task = Task.find(params[:id])
is a string. Running this command generates the various Rails respond_to do |format|
files, including the model, helper, controller, view templates, format.html # show.html.erb
tests and database migration. We’re going to make the simplest format.xml { render :xml => @task }
Todo list in history: Tasks have names, and nothing else. Further- end
more, there are no users even, just a global list of tasks.
end
The Task model looks like this: # GET /tasks/new
class Task < ActiveRecord::Base # GET /tasks/new.xml
end def new
Because the Task model extends (with <) ActiveRecord::Base, it @task = Task.new
can be mapped to the equivalent database tables. Because we respond_to do |format|
also created the controllers and views with the scriptgenerate format.html # new.html.erb
scaffold command and ensured that we specified all the fields, format.xml { render :xml => @task }
we can use a prebuilt web interface to Create, Read, Update,
end
and Delete (CRUD) them.
end
The CreateTasks migration that was created (in dbmigrate001_
# GET /tasks/1/edit
create_tasks.rb) looks like this:
def edit
class CreateTasks < ActiveRecord::Migration @task = Task.find(params[:id])
def self.up
end
create_table :tasks do |t|
# POST /tasks
t.string :name
t.timestamps # POST /tasks.xml
end def create
end @task = Task.new(params[:task])
def self.down respond_to do |format|
drop_table :tasks if @task.save
end
flash[:notice] = 'Task was successfully created.'
end
format.html { redirect_to(@task) }
CreateTasks Class Extends ActiveRecord::Migration format.xml { render :xml => @task,
Up method Creates a new tasks table with the create_table method call, :status => :created, :location => @task }
which takes a block that does the work
else
Down method Deletes it with the drop_table call
format.html { render :action => quot;newquot; }
In the up method, we specify the data types of each new format.xml { render :xml => @task.errors,
column, such as string in our case, or boolean, integer or text. :status => :unprocessable_entity }
These are then mapped to the equivalent database data types: end
for example, boolean becomes a tinyint(1) in MySQL. The end
timestamps call adds two columns: created_at and updated_ end
at, which Rails treats specially, ensuring that they’re automatically
# PUT /tasks/1
set. This is often a good thing to have, so we’ll leave them
# PUT /tasks/1.xml
there even though they won’t be needed in this build. →
DZone, Inc. | www.dzone.com
4. 4
Flexible Rails: Flex 3 on Rails 2
tech facts at your fingertips
Building a Flex + Rails Application, continued
What’s REST?
def update
FYI REST (Representational State Transfer) is a
@task = Task.find(params[:id])
way of building web services that focuses on
respond_to do |format|
simplicity and an architecture style that is “of the web.”
if @task.update_attributes(params[:task])
This can be described as a Resource Oriented Architecture
flash[:notice] = 'Task was successfully updated.'
format.html { redirect_to(@task) }
(ROA); see RESTful Web Services published by O’Reilly Media
format.xml { head :ok }
for details. Briefly, the reason to use a RESTful design in Rails
else is that it helps us organize our controllers better, forces
format.html { render :action => quot;editquot; } us to think harder about our domain, and gives us a nice
format.xml { render :xml => @task.errors, API for free.
:status => :unprocessable_entity }
end
Next, we run the new migration that was created (CreateTasks)
end when we ran the scaffold command:
end
C:todo>rake db:migrate
# DELETE /tasks/1
At this point we run the server:
# DELETE /tasks/1.xml
def destroy C:todo>ruby scriptserver
@task = Task.find(params[:id]) and play with creating, editing and deleting tasks.
@task.destroy
1. Go to http://localhost:3000/tasks to see an empty task list.
respond_to do |format|
format.html { redirect_to(tasks_url) } 2. Click the New link to go to http://localhost:3000/tasks/new.
format.xml { head :ok } 3. Create a new Task with a name of “drink coffee” and
end click Create.
end 4. Go back to http://localhost:3000/tasks to see the task list
end with the new “drink coffee” task present.
This new controller which was generated for us contains the Now, let’s do something interesting and hook this up to Flex.
seven RESTful controller methods, which are explained in Currently, the Todo.mxml file looks like this:
the following table (inspired by David Heinemeier Hansson’s
<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
Discovering a World of Resources on Rails presentation—
<mx:Application xmlns:mx=quot;http://www.adobe.com/
media.rubyonrails.org/presentations/worldofresources.pdf,
2006/mxmlquot; layout=quot;absolutequot;>
slide 7—as well as the table on p. 410 of Agile Web Develop-
ment with Rails, 2nd ed. (The Pragmatic Programmers), </mx:Application>
and the tables in Geoffrey Grosenbach’s REST cheat sheet The top-level tag is mx:Application; the root of a Flex ap-
http://topfunky.com/clients/peepcode/REST-cheatsheet.pdf): plication is always an Application. The mx: part identifies the
XML namespace that the Application component is from. By
# Method Sample Pretend Actual Corres- Corres- default, an Application uses an absolute layout, where you
URL paths HTTP HTTP ponding ponding
Method Method CRUD SQL specify the x,y of each top level container and component.
Method Method
What we want to build is the following application:
1 index /tasks GET GET READ SELECT
/tasks.xml
2 show /tasks/1 GET GET READ SELECT
/tasks/1.xml
3 new /tasks/new GET GET — —
/tasks/new.xml
4 edit /tasks/1/edit GET GET READ SELECT
5 create /tasks POST POST CREATE INSERT
/tasks.xml
6 update /tasks/1 PUT POST UPDATE UPDATE
/tasks/1.xml
7 destroy /tasks/1 DELETE POST DELETE DELETE
/tasks/1.xml
Table 1: The seven standard RESTful controller methods Figure 3: The Simple Todo Flex Application
DZone, Inc. | www.dzone.com
5. 5
Flexible Rails: Flex 3 on Rails 2
tech facts at your fingertips
Building a Flex + Rails Application, continued <mx:Panel title=quot;Simple Todoquot; width=quot;100%quot;
We want the ability to create new tasks, delete tasks and rename height=quot;100%quot;>
them inline in the list. Furthermore, we want to do this in the least <mx:HBox width=quot;100%quot; paddingLeft=quot;5quot;
amount of code possible. Normally, I’d build this iteratively; but paddingRight=quot;5quot;
we’ll build it all at once. Modify the Todo.mxml file to look like this: paddingTop=quot;5quot;>
<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <mx:Label text=quot;New Taskquot;/>
<mx:Application <mx:TextInput id=quot;newTaskTIquot; width=quot;100%quot;
xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot; enter=quot;createTask()quot;/>
width=quot;100%quot; height=quot;100%quot; layout=quot;verticalquot; <mx:Button label=quot;Createquot; click=quot;createTask()quot;/>
backgroundGradientColors=quot;[#000000, #CCCCCC]quot; </mx:HBox>
creationComplete=quot;svcTasksList.send()quot;> <mx:List id=quot;taskListquot; width=quot;100%quot; height=quot;100%quot;
<mx:Script> editable=quot;truequot; labelField=quot;namequot;
<![CDATA[ dataProvider=quot;{tasksXLC}quot;
import mx.events.ListEvent; itemEditEnd=quot;updateSelectedTask(event)quot;/>
import mx.controls.Alert; <mx:ControlBar width=quot;100%quot; horizontalAlign=quot;centerquot;>
import mx.rpc.events.ResultEvent; <mx:Button label=quot;Deletequot; width=quot;100%quot; height=quot;30quot;
private function createTask():void { enabled=quot;{taskList.selectedItem != null}quot;
svcTasksCreate.send(); click=quot;deleteTask(XML(taskList.selectedItem))quot;/>
} </mx:ControlBar>
private function deleteTask(task:XML):void { </mx:Panel>
svcTasksDestroy.url = quot;/tasks/quot; + task.id + quot;.xmlquot;; </mx:Application>
svcTasksDestroy.send({_method: quot;DELETEquot;});
This is a complete Flex application in 67 lines of code! Compile
}
and run the application by clicking the green “play” button: you
private function updateSelectedTask(event:ListEvent): will see the screen shown in Figure 3.
void {
var itemEditor:TextInput = A Quick Highlight Tour of this Code:
TextInput(event.currentTarget.itemEditorInstance);
var selectedTask:XML = XML(event.itemRenderer.data); 1 We use a vertical layout to make the components
if (selectedTask.name == itemEditor.text) return; flow vertically. Other choices are horizontal (for
horizontal flow) and absolute (which we saw before). The
var params:Object = new Object();
backgroundGradientColors specify the start and end of the
params['task[name]'] = itemEditor.text;
gradient fill for the background.
params['_method'] = quot;PUTquot;;
svcTasksUpdate.url = quot;/tasks/quot;+ selectedTask.id +quot;.xmlquot;;
svcTasksUpdate.send(params); We define a HTTPService svcTasksList, which does
2
} a GET to /tasks.xml (thus triggering the index action of
private function listTasks():void { the TasksController) and specifies a resultFormat of e4x so
svcTasksList.send(); the result of the service can be handled with the new E4X
}
XML API. We then take the lastResult of this service, which
is an XML document, get its children (which is an XMLList
]]>
of the tasks), and make this be the source of an XMLList-
</mx:Script> Collection called tasksXLC. We do this with a binding to
<mx:HTTPService id=quot;svcTasksCreatequot; url=quot;/tasks.xmlquot; the source attribute. Similarly, we define svcTasksCreate,
contentType=quot;application/xmlquot; resultFormat=quot;e4xquot; svcTasksUpdate and svcTasksDestroy to be used for the
method=quot;POSTquot; result=quot;listTasks()quot;> other CRUD operations.
<mx:request>
<task><name>{newTaskTI.text}</name></task>
</mx:request> 3 We can pass data to Rails via data bindings using
</mx:HTTPService> curly braces { } inside XML (as shown in svcTaskCreate)
or by sending form parameters that Rails would be expecting
<mx:HTTPService id=quot;svcTasksListquot; url=quot;/tasks.xmlquot;
(as shown in the updateSelectedTask method).
resultFormat=quot;e4xquot; method=quot;POSTquot;/>
<mx:HTTPService id=quot;svcTasksUpdatequot; resultFormat=quot;e4xquot;
method=quot;POSTquot; result=quot;listTasks()quot;/>
4 For svcTasksUpdate and svcTasksDestroy we are
<mx:HTTPService id=quot;svcTasksDestroyquot; resultFormat=quot;e4xquot;
not setting the url property statically, but instead
method=quot;POSTquot; result=quot;listTasks()quot;/> dynamically setting it to include the id of the task we are
<mx:XMLListCollection id=quot;tasksXLCquot; updating or destroying.
source=quot;{XMLList(svcTasksList.lastResult.children())}quot;/>
DZone, Inc. | www.dzone.com