Jan 27

Sending Typed Value Objects from Flex to Rails using WebORB and the [RemoteClass] metadata tag

Tag: Flex and Rails, weborbDerek Wischusen @ 2:14 am

In Part 2 of the tutorials that I have been writing about the Issue Tracker sample app (view, source) I discussed how you can Get Typed Objects from Rails using [RemoteClass]. Now, with the latest version of WebORB, it is also possible send typed objects from Flex to Rails.

This means that you no longer have to use untyped objects or XML to send values from Flex to Rails. Now you can just pass typed value objects back and forth between Flex and Rails.

So now, in the Issue Tracker sample app, when an IssueVO is sent from Flex to Rails, because it is mapped to the Issue ActiveRecord class (using the process that is explained in Part 2), it automatically gets converted to an Issue ActiveRecord instance. If the value of the id attribute on the IssueVO matches an existing Issue ActiveRecord then WebORB will return that object, otherwise it will create a new ActiveRecord instance.

This makes it possible to simplify the updateIssue method as follows:

  def updateIssue(issue)
    issue.save
  end

11 Responses to “Sending Typed Value Objects from Flex to Rails using WebORB and the [RemoteClass] metadata tag”

  1. Mark Wales says:

    Derek – you are really doing a great job of putting WebORB through its paces – and publishing the result. Great work!

  2. Frank says:

    Cool. Does WebOrb hold on to a reference to any Issue object sent to Flex? Or do we need to keep a reference around to it (on the rails side) in order for there to be “an existing issue ActiveRecord” ?
    Thanks.

  3. Derek Wischusen says:

    Frank – WebORB checks the database to see if the object exists by using ActiveRecord’s exists? method. So you do not have to keep your own reference to it on the Rails side.

    The code looks something like this:

    ActiveRecord.exists?(@flex_object_attributes[ActiveRecord.primary_key])

    Where flex_object_attributes is a hash that contains all of the values from the object that is sent over from Flex.

    Derek

  4. Robert Shiue says:

    Thanks Derek! Your article is greatly helpful. :)
    Is that possible sending ArrayCollection object from Flex to Ruby via WebORB? Or all I could do is ArrayCollection.toArray() ,then send it?

    Thanks again. You are great.

    Robert

  5. Derek Wischusen says:

    Hi Robert,

    Your best bet would be to send covert the ArrayCollection to an Array first, and then send it over to Rails.

    If you try to send an ArrayCollection you will get an error because there is no ArrayCollection class in Rails/Ruby and Rails will not know what to do with it.

  6. Robert Shiue’s Blog » Blog Archive » [Flex]Cannot send ArrayCollection to ROR via Weborb says:

    [...] Thanks Derek. So I must call toArray() while sending ArrayCollection data. you can read the reply here. [...]

  7. Martin says:

    Derek,

    I noticed your reference to the simplified version of the updateIssue method, but I did not find it implemented that way in the IssueTracker2 code. Do I have an old version?

    Martin

  8. Derek Wischusen says:

    Hi Martin,

    No, I have been working on an update to this app that will include this change and some other features, but it’s not quite done yet. I hope to have it done by next month.

    Best,
    Derek

  9. David Blais says:

    i’m sending arraycollection to Ruby from Flex and i’m receiving arraycollection directly to Flex!

    Ruby will receive arraycollection if you map it in the file weborb-config.xml:

    flex.messaging.io.ArrayCollection
    ObjectProxy
    weborb.v3types.ObjectProxy

    And if you want send arraycollection from Ruby to Flex is a little harder…
    Edit the file message_writer.rb.
    Replace line->
    write_array_method = writer_class.method :write_array
    by
    write_array_method = writer_class.method :write_array_collection

    And this function to the same file
    def MessageWriter.write_array_collection( data_object, formatter )
    formatter.begin_write_array_collection()
    write_array(data_object, formatter)
    end

    and finally edit amfv3_formatter.rb and add this function:
    def begin_write_array_collection()
    @writer.write_byte( 0×0a )
    @writer.write_byte( 0×07 )
    @writer.write_utf( “flex.messaging.io.ArrayCollection”, true )
    end

    Now all array from Ruby will be send as ArrayCollection in Flex.

    I think is working well :P

  10. shajahan says:

    hi,
    as u said i’m able to configure ruby for arraycollection. but can you tell me how to store the array collection which comes from a VO object to the ruby function in the database. i’m new to ruby and i don’t find an example for this.i’ll be greatful; if can send me a sample code of rails function which recieves the arraycollection from the flex and store in a database
    Thanks,
    Shajahan

  11. Shawn Makinson says:

    I am investigating the ruby version of weborb and I am running into an issue. I am sending a mapped class that contains an array of another mapped class to rails for saving. The problem I am having is by the time my flash class makes it to the rails method it has already decided to look up the data for the items in the array and ends up overwriting the data in the original argument from flash. So basically it ends up not getting the new data and running an update with the same data.

    Flash class:

    class Foo{
    public var id:uint;
    public var blahArray:Array;
    }

    class Blah{
    public var id:uint;
    public var name:String;
    }

    So if the the blahArray contains items that already have an id, they get looked up when I pass a foo instance to be saved before I get to call save with the new data for name. I have confirmed this by looking at the sql that runs. Am I missing something, to me this defeats the purpose of even using this stuff. I would appreciate any suggestions at all.

    Thanks!

Leave a Reply

Generic cialis overnight
Free samples of cialis
Overnight delivery viagra
Cheapest generic viagra online
Order viagra without prescription
Pfizer viagra price
Buy cialis brand
Phentermine buy australia
Buy viagra online in australia
Order phentermine online no prescription
Buy phentermine hcl 37.5 no prescription
Cheap levitra no prescription
Viagra without prescription uk
Xanax 1mg
Valium 10 mg
Prescription viagra canada
10mg prednisone
Cialis online canadian pharmacy
Valium online fast delivery
Cheapest online cialis
No prescription cialis online
Viagra cheapest
Viagra online shop
Buy propecia
How to buy phentermine online
Buying levitra without prescription
Propecia ireland
Buy valium without prescription uk
Viagra price canada
Low price viagra
Order cheap viagra online
Overnight xanax delivery
Buying viagra online
Generic viagra 100mg
2.5mg cialis
Online prescription tramadol
Buy valium europe
Cialis canada no prescription
Buy viagra uk no prescription
Discount viagra online
Xanax bars side effects
Where can i buy viagra in the uk
Valium online overnight
Generic levitra uk
Viagra shop online
Phentermine online free shipping
Phentermine online uk
Best price tramadol
Tramadol without prescription overnight delivery
Cheap levitra uk
Buy phentermine online without prescription
Purchase phentermine
Buy valium cheap online
Where to buy viagra in england
Viagra no prescription online
Propecia generic cost
Cheap cialis
100mg tramadol effects
Tramadol online overnight
Buy generic cialis
Xanax buy uk
Buying prednisone online
Buy xanax 2mg no prescription
No prescription valium
Cheap generic viagra
Best viagra dose
Order tramadol overnight
Buy viagra online in ireland
Buy generic valium
Cialis 20mg
Brand viagra cheap
Xanax bars effects
Phentermine canada no prescription
Viagra prescription
Cheap xanax bars
Propecia 1mg generic
Cheap phentermine without prescription
Real phentermine without prescription
Cheap generic valium
Discount viagra pills
Online prescriptions xanax
Viagra fast delivery
Low cost levitra
Pharmacy tramadol
Viagra discount coupons
Best viagra alternative
Dose of xanax
Side effects of viagra
Viagra for sale online
Levitra on sale
Authentic phentermine 37.5
10mg valium effects
Propecia cost
Dosage of xanax
Viagra canada prices
Cheap viagra online without prescription
Prednisone 20mg side effects
Valium generic
Buying cialis online without a prescription
Viagra super active
Low price cialis
Buying viagra in london
Generic viagra super active
How to buy valium without a prescription
Viagra pharmacy prices
Levitra 20mg
Propecia generic canada
Cheap cialis india
Phentermine cheap online
Buy viagra from canada
Cheapest levitra
Xanax online cheap
Cialis discount price
Free cialis online
Buy phentermine no script
Viagra canada mastercard
Buy viagra online cheap
Viagra express delivery
Where can i buy viagra without a prescription
Tramadol india
Cialis 20 mg dosage
Viagra professional online
Get viagra prescription
Fedex tramadol
Best price on phentermine
Cialis samples canada
Best way to buy viagra online
Viagra pharmacy uk
Where to buy cialis without prescription
Where to buy viagra online
Buy generic cialis uk
Buying tramadol in uk
Buy cialis in the uk
Cialis over the counter
Tramadol no prescription required
Cheap xanax for sale
Prescription viagra uk
Xanax with no prescription
Canada viagra no prescription
Buy generic cialis online
Ordering propecia from canada

Where to buy propecia in canada
Purchase viagra online without prescription
Cialis prices uk
Viagra generic cheap
Generic viagra for sale
Blood pressure and prednisone
Buy xanax online without prescription
Viagra discount prices
Levitra online cheap
Where can i buy viagra without prescription
Phentermine 37.5 wholesale
Tramadol free shipping
Buy tramadol hcl
Buy levitra
Buy viagra uk online
Viagra cheap no prescription
Xanax for sale without prescription
Buy phentermine 37.5mg pills
Phentermine 37.5 buy online
Order prednisone no prescription
Order tramadol cod
Buy cheap valium online
Viagra generic
Xanax no prescription overnight
Viagra online cheap
Mail order phentermine
Generic viagra sales
Cheap cialis viagra
Viagra pills for sale
Prescription valium
Propecia cheap
Tramadol cod delivery
Propecia price australia
Cialis prescription cost
Xanax generic dosage
Xanax price per pill
Xanax 1 mg dose
Valium cheapest
Prescription free viagra
Phentermine canadian pharmacy
Buy xanax canada
Buy generic phentermine online
Viagra 50 mg online without prescription
Cheapest place to buy viagra online
Canada viagra
Buy cialis uk
Levitra samples
Where to buy levitra online
Xanax no prescription required
Xanax overnight cod
Viagra buy online no prescription
Overnight tramadol no prescription
Buy viagra in england
Propecia uk pharmacy
Propecia usa
Cialis soft tabs online
Levitra price
Low cost cialis
Cialis price
Valium online uk
Buy cialis viagra
Generic xanax xr
Viagra tablets for sale
Viagra in the uk
Viagra in france
Prednisone tablets 10 mg
Order xanax cod
Tramadol no prescription overnight delivery
Viagra in usa
Cialis medication
Where to buy cialis online
Generic xanax no prescription
Australia viagra prescription
Phentermine purchase online
Cialis order online
Buy brand name viagra
Cialis side effects
Cialis uk sales
Propecia uk prices
Phentermine 37.5mg
Buying viagra in new zealand
Viagra canadian online pharmacy
40 mg prednisone side effects
Viagra purchase uk
Viagra ordering
Cialis 20mg side effects
Valium no rx
Australia viagra online
Tramadol online no prescription overnight
Generic cialis uk
Phentermine 37.5 pills
Buy generic xanax no prescription
Xanax 0.5 mg
Cialis cialis
Valium online pharmacy
Buy viagra australia
Viagra india price
Viagra dosage information
Best levitra prices
Buy pfizer viagra without prescription
Buy propecia online without a prescription
Viagra to buy
Phentermine without a prescription
Discount viagra india
Levitra us
Order xanax online
Tramadol medication
Prescription propecia