SlideShare une entreprise Scribd logo
1  sur  17
Télécharger pour lire hors ligne
Rails GUI Development
       with Ext JS
    martin.rehfeld@glnetworks.de
       @ RUG-B 10-Jan-2008
What‘s wrong with
ActionView::Helpers ?
• Nothing!
• But...
 • often feels like assembling a spacecraft
    molecule by molecule
  • which is fine for building the one GUI that
    no one else has, but get‘s boring for
    standard apps
Wouldn‘t it be nice, if...

• ... you had rich GUI components like
 • Data Grids
 • Tree Views
 • Tabs
 • Toolbars / Menus
Maybe Ext JS is for you




       http://www.extjs.com
Ext JS
• JavaScript Framework
• Dual-License: LGPL + Commercial
 • rich GUI components
 • interface to JSON or XML based
    data sources (~ web services)
 • keeps state in session, i.e. cookies
 •           cross-browser
    6+ 1.5+ 2+   9+
Segregation of Duties

•   Model: business as usual    •   program GUI and
                                    interactions in JavaScript
•   Controller: REST web
    service providing           •   use Rails backend to load
    special :ext_json format,       and persist data as needed
    handle page flow /
    redirects

•   View: provide layout,
    DOM structure and
    include JavaScript
Test Drive: Scaffolding
                          Data Grid with
                          toolbar and pagination




 Forms with validation
 (client side + server side)
Demo
Ext Scaffold Generator
• Create Rails app
  rails ext_demo


• Download & extract Ext to public/ext
  http://extjs.com/deploy/ext-2.0.zip


• Install ext_scaffold plugin:
  script/plugin install http://rug-b.rubyforge.org/svn/ext_scaffold


• Generate Demo resource
  script/generate ext_scaffold Post title:string body:text
  published:boolean visible_from:datetime visible_to:date ;
  rake db:migrate


• Enjoy :-)
  script/server -> http://localhost:3000/posts
Code
Model
• Nothing special :-)
  class Post < ActiveRecord::Base
    validates_presence_of :title, :message => quot;Title can't be blankquot;
  end



• Validation errors will be presented in forms
  just as Ext‘s own (client side) validation
  failures
• Ext Scaffold will return JSON error
  structure with per-field messages
Controller
• Support ext_json format -> render :json
  def index
    respond_to do |format|
      format.html     # index.html.erb (no data required)
      format.ext_json { render :json => Post.find(:all).to_ext_json }
    end
  end

  def create
    @post = Post.new(params[:post])

    respond_to do |format|
      if @post.save
        flash[:notice] = 'Post was successfully created.'
        format.ext_json { render(:update) {|page| page.redirect_to posts_url } }
      else
        format.ext_json { render :json => @post.to_ext_json(:success => false) }
      end
    end
  end

  ...
#to_ext_json ?
• Implemented as extension to Array and
  ActiveRecord::Base respectively
 • Array form
    {quot;resultsquot;: n,
      quot;postsquot;: [ {quot;idquot;: 1, quot;titlequot;: quot;First Postquot;,
                  quot;bodyquot;: quot;This is my first post.quot;, quot;publishedquot;: true, ... },
                  ...
               ]
    }




 • Single (valid) record
    {quot;dataquot;: { quot;post[id]quot;: 1, quot;post[title]quot;: quot;First Postquot;,
               quot;post[body]quot;: quot;This is my first post.quot;,
               quot;post[published]quot;: true, ...},
     quot;successquot;: true}
View
• Supported by (some tiny) helpers
  <% javascript_tag do -%>
    var post_form_items = [
       <%= ext_field(:field_label => 'Title', :name => 'post[title]',
                     :xtype => :text_field) %>,
       <%= ext_field(:field_label => 'Body', :name => 'post[body]',
                     :xtype => :text_area) %>,
       <%= ext_field(:field_label => 'Published', :name => 'post[published]',
                     :xtype => :check_box) %>,
       <%= ext_field(:field_label => 'Visible from', :name => 'post[visible_from]',
                     :xtype => :datetime_select) %>,
       <%= ext_field(:field_label => 'Visible to', :name => 'post[visible_to]',
                     :xtype => :date_select) %>
    ];
  <% end -%>

  <%= ext_form_for :post,
                   :element => 'post-form',
                   :form_items => :post_form_items,
                   :mode => :new %>
  <div id=quot;post-formquot;></div>
Resulting „HTML“
<script type=quot;text/javascriptquot;>
  var post_form_items = [
    { fieldLabel: 'Title',     xtype:   'textfield',                 name:   'post[title]'},
    { fieldLabel: 'Body',      xtype:   'textarea',                  name:   'post[body]'},
    { fieldLabel: 'Published', xtype:   'checkbox', inputValue: '1', name:   'post[published]'},
                             { xtype:   'hidden',        value: '0', name:   'post[published]' },
    ...
  ];

  Ext.onReady(function(){
    var panel = new Ext.FormPanel({
        url:        '/posts',
        title:      'Create Post',
        renderTo:   'post-form',
        baseParams: {authenticity_token: 'my_secret'},
        items:      post_form_items,
        buttons:    [ { text: 'Save', type: 'submit',
                          handler: function(){
                            panel.form.submit({url:    '/posts?format=ext_json',
                                               waitMsg:'Saving...'}); }},
                      { text: 'Back', handler: function(){ window.location.href = '/posts'; } }
                    ]
    });
  });
</script>
<div id=quot;post-formquot;></div>
Conclusion
• Using Ext gives
 • a very slim Rails backend,
    just as we like it            :-)
 • lots of JavaScript in the view :-(
 • then again:
    loads of functionality „for free“ and less
    involvement of the backend in user
    interactions                   :-))))
Q &A



!   Martin Rehfeld
    martin.rehfeld@glnetworks.de
    http://inside.glnetworks.de

Contenu connexe

Tendances

Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0Eyal Vardi
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile ProcessEyal Vardi
 
Performance Optimization In Angular 2
Performance Optimization In Angular 2Performance Optimization In Angular 2
Performance Optimization In Angular 2Eyal Vardi
 
Getting classy with ES6
Getting classy with ES6Getting classy with ES6
Getting classy with ES6Andy Sharman
 
Angular 2.0 Views
Angular 2.0 ViewsAngular 2.0 Views
Angular 2.0 ViewsEyal Vardi
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajaxbaygross
 
amsterdamjs - jQuery 1.5
amsterdamjs - jQuery 1.5amsterdamjs - jQuery 1.5
amsterdamjs - jQuery 1.5mennovanslooten
 
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.xAngular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.xEyal Vardi
 
Drupal sins 2016 10-06
Drupal sins 2016 10-06Drupal sins 2016 10-06
Drupal sins 2016 10-06Aaron Crosman
 
Game jump: frontend introduction #1
Game jump: frontend introduction #1Game jump: frontend introduction #1
Game jump: frontend introduction #1Sebastian Pożoga
 
Sins Against Drupal 2
Sins Against Drupal 2Sins Against Drupal 2
Sins Against Drupal 2Aaron Crosman
 
Modules and injector
Modules and injectorModules and injector
Modules and injectorEyal Vardi
 
Iterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory managementIterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory managementAdrian Cardenas
 
Routing And Navigation
Routing And NavigationRouting And Navigation
Routing And NavigationEyal Vardi
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS OverviewEyal Vardi
 

Tendances (20)

Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0
 
22 j query1
22 j query122 j query1
22 j query1
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
 
Performance Optimization In Angular 2
Performance Optimization In Angular 2Performance Optimization In Angular 2
Performance Optimization In Angular 2
 
Getting classy with ES6
Getting classy with ES6Getting classy with ES6
Getting classy with ES6
 
Angular 2.0 Views
Angular 2.0 ViewsAngular 2.0 Views
Angular 2.0 Views
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
 
amsterdamjs - jQuery 1.5
amsterdamjs - jQuery 1.5amsterdamjs - jQuery 1.5
amsterdamjs - jQuery 1.5
 
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.xAngular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.x
 
Drupal sins 2016 10-06
Drupal sins 2016 10-06Drupal sins 2016 10-06
Drupal sins 2016 10-06
 
Game jump: frontend introduction #1
Game jump: frontend introduction #1Game jump: frontend introduction #1
Game jump: frontend introduction #1
 
Sins Against Drupal 2
Sins Against Drupal 2Sins Against Drupal 2
Sins Against Drupal 2
 
Modules and injector
Modules and injectorModules and injector
Modules and injector
 
Iterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory managementIterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory management
 
Routing And Navigation
Routing And NavigationRouting And Navigation
Routing And Navigation
 
jQuery basics
jQuery basicsjQuery basics
jQuery basics
 
Symfony2. Form and Validation
Symfony2. Form and ValidationSymfony2. Form and Validation
Symfony2. Form and Validation
 
J Query Public
J Query PublicJ Query Public
J Query Public
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS Overview
 
5. hello popescu
5. hello popescu5. hello popescu
5. hello popescu
 

En vedette

Gui Development with qooxdoo
Gui Development with qooxdooGui Development with qooxdoo
Gui Development with qooxdooSebastian Werner
 
Gui application development guidelines
Gui application development guidelinesGui application development guidelines
Gui application development guidelinesLOUIS WAYNE
 
Graphical User Interface
Graphical User Interface Graphical User Interface
Graphical User Interface Bivek Pakuwal
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)Bilal Amjad
 

En vedette (7)

01 gui 01
01 gui 0101 gui 01
01 gui 01
 
Gui Development with qooxdoo
Gui Development with qooxdooGui Development with qooxdoo
Gui Development with qooxdoo
 
02 gui 02
02 gui 0202 gui 02
02 gui 02
 
Gui application development guidelines
Gui application development guidelinesGui application development guidelines
Gui application development guidelines
 
Graphical User Interface
Graphical User Interface Graphical User Interface
Graphical User Interface
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)
 
Macintosh vs. windows
Macintosh vs. windowsMacintosh vs. windows
Macintosh vs. windows
 

Similaire à Rails GUI Development with Ext JS

Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous MerbMatt Todd
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3masahiroookubo
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsMike Subelsky
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsMike Subelsky
 
Acceptance Testing with Webrat
Acceptance Testing with WebratAcceptance Testing with Webrat
Acceptance Testing with WebratLuismi Cavallé
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Foreverstephskardal
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosIgor Sobreira
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialYi-Ting Cheng
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
GHC Participant Training
GHC Participant TrainingGHC Participant Training
GHC Participant TrainingAidIQ
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of usOSCON Byrum
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
Aprimorando sua Aplicação com Ext JS 4 - BrazilJS
Aprimorando sua Aplicação com Ext JS 4 - BrazilJSAprimorando sua Aplicação com Ext JS 4 - BrazilJS
Aprimorando sua Aplicação com Ext JS 4 - BrazilJSLoiane Groner
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoRob Bontekoe
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkDirk Haun
 

Similaire à Rails GUI Development with Ext JS (20)

Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous Merb
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
 
Java script
Java scriptJava script
Java script
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Rails <form> Chronicle
Rails <form> ChronicleRails <form> Chronicle
Rails <form> Chronicle
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Acceptance Testing with Webrat
Acceptance Testing with WebratAcceptance Testing with Webrat
Acceptance Testing with Webrat
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazos
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
Jsf Ajax
Jsf AjaxJsf Ajax
Jsf Ajax
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
GHC Participant Training
GHC Participant TrainingGHC Participant Training
GHC Participant Training
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of us
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Aprimorando sua Aplicação com Ext JS 4 - BrazilJS
Aprimorando sua Aplicação com Ext JS 4 - BrazilJSAprimorando sua Aplicação com Ext JS 4 - BrazilJS
Aprimorando sua Aplicação com Ext JS 4 - BrazilJS
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 

Dernier

Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service NoidaCall Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service Noidadlhescort
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...amitlee9823
 
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLBAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLkapoorjyoti4444
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...lizamodels9
 
Business Model Canvas (BMC)- A new venture concept
Business Model Canvas (BMC)-  A new venture conceptBusiness Model Canvas (BMC)-  A new venture concept
Business Model Canvas (BMC)- A new venture conceptP&CO
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsP&CO
 
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al MizharAl Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizharallensay1
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756dollysharma2066
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...allensay1
 
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceEluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceDamini Dixit
 
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂EscortCall Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escortdlhescort
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Centuryrwgiffor
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceMalegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceDamini Dixit
 
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...lizamodels9
 
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...Anamikakaur10
 
Falcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon investment
 

Dernier (20)

Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service NoidaCall Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
 
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLBAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
 
Business Model Canvas (BMC)- A new venture concept
Business Model Canvas (BMC)-  A new venture conceptBusiness Model Canvas (BMC)-  A new venture concept
Business Model Canvas (BMC)- A new venture concept
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and pains
 
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al MizharAl Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
 
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceEluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
 
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂EscortCall Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Century
 
Falcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in indiaFalcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in india
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceMalegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
 
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
 
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
 
Falcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business Growth
 
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
 

Rails GUI Development with Ext JS

  • 1. Rails GUI Development with Ext JS martin.rehfeld@glnetworks.de @ RUG-B 10-Jan-2008
  • 2. What‘s wrong with ActionView::Helpers ? • Nothing! • But... • often feels like assembling a spacecraft molecule by molecule • which is fine for building the one GUI that no one else has, but get‘s boring for standard apps
  • 3. Wouldn‘t it be nice, if... • ... you had rich GUI components like • Data Grids • Tree Views • Tabs • Toolbars / Menus
  • 4. Maybe Ext JS is for you http://www.extjs.com
  • 5. Ext JS • JavaScript Framework • Dual-License: LGPL + Commercial • rich GUI components • interface to JSON or XML based data sources (~ web services) • keeps state in session, i.e. cookies • cross-browser 6+ 1.5+ 2+ 9+
  • 6. Segregation of Duties • Model: business as usual • program GUI and interactions in JavaScript • Controller: REST web service providing • use Rails backend to load special :ext_json format, and persist data as needed handle page flow / redirects • View: provide layout, DOM structure and include JavaScript
  • 7. Test Drive: Scaffolding Data Grid with toolbar and pagination Forms with validation (client side + server side)
  • 9. Ext Scaffold Generator • Create Rails app rails ext_demo • Download & extract Ext to public/ext http://extjs.com/deploy/ext-2.0.zip • Install ext_scaffold plugin: script/plugin install http://rug-b.rubyforge.org/svn/ext_scaffold • Generate Demo resource script/generate ext_scaffold Post title:string body:text published:boolean visible_from:datetime visible_to:date ; rake db:migrate • Enjoy :-) script/server -> http://localhost:3000/posts
  • 10. Code
  • 11. Model • Nothing special :-) class Post < ActiveRecord::Base validates_presence_of :title, :message => quot;Title can't be blankquot; end • Validation errors will be presented in forms just as Ext‘s own (client side) validation failures • Ext Scaffold will return JSON error structure with per-field messages
  • 12. Controller • Support ext_json format -> render :json def index respond_to do |format| format.html # index.html.erb (no data required) format.ext_json { render :json => Post.find(:all).to_ext_json } end end def create @post = Post.new(params[:post]) respond_to do |format| if @post.save flash[:notice] = 'Post was successfully created.' format.ext_json { render(:update) {|page| page.redirect_to posts_url } } else format.ext_json { render :json => @post.to_ext_json(:success => false) } end end end ...
  • 13. #to_ext_json ? • Implemented as extension to Array and ActiveRecord::Base respectively • Array form {quot;resultsquot;: n, quot;postsquot;: [ {quot;idquot;: 1, quot;titlequot;: quot;First Postquot;, quot;bodyquot;: quot;This is my first post.quot;, quot;publishedquot;: true, ... }, ... ] } • Single (valid) record {quot;dataquot;: { quot;post[id]quot;: 1, quot;post[title]quot;: quot;First Postquot;, quot;post[body]quot;: quot;This is my first post.quot;, quot;post[published]quot;: true, ...}, quot;successquot;: true}
  • 14. View • Supported by (some tiny) helpers <% javascript_tag do -%> var post_form_items = [ <%= ext_field(:field_label => 'Title', :name => 'post[title]', :xtype => :text_field) %>, <%= ext_field(:field_label => 'Body', :name => 'post[body]', :xtype => :text_area) %>, <%= ext_field(:field_label => 'Published', :name => 'post[published]', :xtype => :check_box) %>, <%= ext_field(:field_label => 'Visible from', :name => 'post[visible_from]', :xtype => :datetime_select) %>, <%= ext_field(:field_label => 'Visible to', :name => 'post[visible_to]', :xtype => :date_select) %> ]; <% end -%> <%= ext_form_for :post, :element => 'post-form', :form_items => :post_form_items, :mode => :new %> <div id=quot;post-formquot;></div>
  • 15. Resulting „HTML“ <script type=quot;text/javascriptquot;> var post_form_items = [ { fieldLabel: 'Title', xtype: 'textfield', name: 'post[title]'}, { fieldLabel: 'Body', xtype: 'textarea', name: 'post[body]'}, { fieldLabel: 'Published', xtype: 'checkbox', inputValue: '1', name: 'post[published]'}, { xtype: 'hidden', value: '0', name: 'post[published]' }, ... ]; Ext.onReady(function(){ var panel = new Ext.FormPanel({ url: '/posts', title: 'Create Post', renderTo: 'post-form', baseParams: {authenticity_token: 'my_secret'}, items: post_form_items, buttons: [ { text: 'Save', type: 'submit', handler: function(){ panel.form.submit({url: '/posts?format=ext_json', waitMsg:'Saving...'}); }}, { text: 'Back', handler: function(){ window.location.href = '/posts'; } } ] }); }); </script> <div id=quot;post-formquot;></div>
  • 16. Conclusion • Using Ext gives • a very slim Rails backend, just as we like it :-) • lots of JavaScript in the view :-( • then again: loads of functionality „for free“ and less involvement of the backend in user interactions :-))))
  • 17. Q &A ! Martin Rehfeld martin.rehfeld@glnetworks.de http://inside.glnetworks.de