nextwebgen.com

The Next Generation Web Now

Ajax File uploads to Amazon S3

Filed under: Web 2.0 News, Front Page, Articles, Ruby, Dojo — Dion Almaer at 10:05 am on Friday, July 21, 2006

Raphael Bauduin has written about his experience converting a Rails remote form into a dojo.io.bind call that enables him to upload a file:

File uploads are finally deployed! You can now specify in MyOwnDB that a detail of your entity is of the type “file”. This will let you attach a file to an entry, and subsequently replace or delete it. This required some changes in the application, more specifically in the way the forms are submitted back to the server.

For a file upload to work fine, you have to send it with the enctype attribute set to “multipart/form-data”. But that’s not all! You cannot just serialize the form in javascript like you can do with other input types because you cannot access the file from Javascript. The reason for this is security.

Luckily, the Dojo javascript toolkit has a workaround that works amazingly well, and is really easy to put in place. Dojo is facilitating all XMLHttprequest thanks to its dojo.io.bind method, which I discovered thanks to an article correctly title “Introduction to dojo.io.bind“. This article shows that dojo.io.bind can be used to send simple GET or POST request, but also to submit forms. At first, I thought it didn’t support file uploads (as stated in the document), but it does amazingly well. And, best of all, it is cross browser.

How does it work?

Dojo transparently creates an IFRAME, and submits the form through that IFRAME. That way, the browser itself is submitting the file. This has the side effect that you loose some functionality compared to XMLHttpRequests, like illustrated by the last remarks above.
I’m really happy with the result and the simplicity of the code. It allowed me to not touch any code outside of the form submission, and treat all form in the same way. When I started coding this, Dojo was the only solution I found, but Yahoo!’s YUI lib has gained the same functionality with its connection manager, taking the same approach of creating an IFRAME.

Juggernaut: Comet for Rails?

Filed under: Web 2.0 News, Front Page, Toolkit, Ruby, Comet — Dion Almaer at 8:41 am on Thursday, July 20, 2006

Alex MacCaw has released a plugin for Ruby on Rails that “aims to revolutionize your Rails app by letting the server initiate a connection and push data to the client. In other words your app can have a real time connection to the server with the advantage of instant updates.”

The plugin Juggernaut initiates a flash xmlsocket between server and browser allowing real time communication between the two. The open socket connection allows the server to ‘push’ base64 encoded javascript to the browser which is subsequently decoded and evaluated.

I see this as Comet for Rails, as it is about the interaction model not technology (e.g. if Flash or not). Alex may disagree :)

Frequently Asked Questions

What flash version does Juggernaut use?

Flash socket uses version 6 which is supported by more than 95% of users.

Does it work in all browsers?

It works in all the major ones: Firefox 1+, IE 6+ and Safari 2+.

What are the advantages/disadvantages of using a flash socket over other methods?

It’s better than comet because:

  • It’s much less of a hack
  • It doesn’t crash your browser (Comet can do this after a while)
  • 95% of browsers support it (flash 6).
  • It’s much easier to implement
  • It can use a different port - unlike comet - so you don’t need any custom dispatch servlets for forwarding messages through rails to the push server - it can connect directly.

It’s better than polling because:

  • Much cleaner
  • Doesn’t use as many server resources

Tuesday Morning Roundup

Filed under: Web 2.0 News, Front Page, JavaScript, Safari, Prototype, Ruby, Scriptaculous, RichTextWidget, Tip — Rob Sanheim at 9:00 am on Tuesday, July 11, 2006

Tuesday morning roundup!

  • Lesserwiki - a very light Ruby on Rails wiki very similiar to TiddlyWiki, with all updates done continuously on one page, double click to edit, etc.
  • Article on Writing Custom Iterators for Prototype from Encytemedia
  • A Prototype solution to the DOM Ready issue (see Dean's post for background info)
  • Javascript object < -> Rails object marshalling capability has been integrated into Protowidget - demo here, detailed explanation here - looks cool and could also function on its own.
  • An Ajax-ready slide transition library (demo) based on the popular Prototype/scriptaculous combo.
  • Reducing the perceived responsiveness of your app with the "W AJAX" design pattern - using background threads on the server to load complex data while the browser continues to load the easy stuff.
  • Safari hates trailing commas like this:
    new Effect.Highlight('foo', {duration:0.5,startcolor:'#ff99ff',});
    while FF and IE don't care. Bruce Williams has a quick and dirty Ruby test case to find offending scripts so you can catch it early in your build.

Sifl n Olly's Chester on his love skills. (mp3, probably NSFW)

updated: made title less stupid

RailsConf 2006: Rails on Ajax by Justin Gehtland

Filed under: Web 2.0 News, Front Page, Ajax, Prototype, Conference, Ruby, Presentation — Rob Sanheim at 2:09 pm on Saturday, June 24, 2006

(Note From Rob: This session write up comes courtesy of Jim Halberg. Jim is not an official Ajaxian, though he dreams about being one when he grows up. Thanks, Jim!)

Are we still at the point where a talk on ajax must start with the "What is ajax?" question? Well, at least the explanations seem to be getting shorter =) (Rob: note to conference speakers - can we please just assume basic Ajax knowledge at this point?!)

Justin spent the majority of the presentation showing uncluttered examples of various Rails/Ajax/Prototype capabilities. Auto-complete search, drag-drop, and the like. These were delivered in a "if you haven't played with this yet" sort of way but he also managed to keep it quick enough - and drop in enough 'even if you've done this before you may not know about this' tidbits to keep the more experienced portion of the audience interested.

There was some talk on RJS and he spent some time on the always requested ajax topics… How do you deal with JavaScript disabled? What if a user has an old browser? How do you handle the introduction of new idioms?

The presentation ended with a bang as he demo'd creating an application with the soon to be released Streamlined. Streamlined is an open source framework, developed by Relevance LLC, to bring the simplicity of ActiveRecord to the view layer (coincidentally, this is #2 of the "3 Unsolved Problems" posed in Dave Thomas keynote yesterday). This is really slick - a lot of functionality - good looking (although they are looking for a designer to contribute some improvements) - and best of all: _very_ quick and powerful. I'm definitely looking forward to this being released at OSCON.

Ajaxians invade RailsConf 2006

Filed under: Web 2.0 News, Front Page, Conference, Ruby, Web20 — Rob Sanheim at 12:01 am on Friday, June 23, 2006

Well, at least I'll be heading to RailsConf tomorrow morning, and attempting to live blog as much ajax related content as possible. Ajaxian-in-training and coworker Jim Halberg will be there, as well. If Dion can recover from his twenty hours of flying, he might also make a celebrity appearance. If any readers are heading down and would like to hit up a bar or club, just holler at us.

As for Ajax sessions, I'll be attending Rails, Ajax and Universal Design, Lazlo on Rails, and possibly Justin's Ajax on Rails. Are there other sessions you would like to see coverage of from Ajaxian? If we cover non-Ajax specific sessions here, will you be pissed off? Will we ever fix the comment system?

We put these pressing questions to you, the Ajax community.