SlideShare a Scribd company logo
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

More Related Content

What's hot

Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0
Eyal Vardi
 
22 j query1
22 j query122 j query1
22 j query1
Fajar Baskoro
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
Eyal Vardi
 
Performance Optimization In Angular 2
Performance Optimization In Angular 2Performance Optimization In Angular 2
Performance Optimization In Angular 2
Eyal Vardi
 
Getting classy with ES6
Getting classy with ES6Getting classy with ES6
Getting classy with ES6
Andy Sharman
 
Angular 2.0 Views
Angular 2.0 ViewsAngular 2.0 Views
Angular 2.0 Views
Eyal 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.5
mennovanslooten
 
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
Eyal Vardi
 
Drupal sins 2016 10-06
Drupal sins 2016 10-06Drupal sins 2016 10-06
Drupal sins 2016 10-06
Aaron Crosman
 
Game jump: frontend introduction #1
Game jump: frontend introduction #1Game jump: frontend introduction #1
Game jump: frontend introduction #1
Sebastian Pożoga
 
Sins Against Drupal 2
Sins Against Drupal 2Sins Against Drupal 2
Sins Against Drupal 2
Aaron Crosman
 
Modules and injector
Modules and injectorModules and injector
Modules and injector
Eyal 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 management
Adrian Cardenas
 
Routing And Navigation
Routing And NavigationRouting And Navigation
Routing And Navigation
Eyal Vardi
 
jQuery basics
jQuery basicsjQuery basics
jQuery basics
Stijn Van Minnebruggen
 
Symfony2. Form and Validation
Symfony2. Form and ValidationSymfony2. Form and Validation
Symfony2. Form and Validation
Vladimir Doroshenko
 
J Query Public
J Query PublicJ Query Public
J Query Public
pradeepsilamkoti
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS Overview
Eyal Vardi
 
5. hello popescu
5. hello popescu5. hello popescu
5. hello popescu
Razvan Raducanu, PhD
 

What's hot (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
 

Viewers also liked

Gui Development with qooxdoo
Gui Development with qooxdooGui Development with qooxdoo
Gui Development with qooxdoo
Sebastian 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
 
Macintosh vs. windows
Macintosh vs. windowsMacintosh vs. windows
Macintosh vs. windows
Daniel Edward Ricio
 

Viewers also liked (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
 

Similar to Rails GUI Development with Ext JS

Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous Merb
Matt Todd
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
masahiroookubo
 
Java script
Java scriptJava script
Java script
Fajar Baskoro
 
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
 
Rails <form> Chronicle
Rails <form> ChronicleRails <form> Chronicle
Rails <form> Chronicle
Kyosuke MOROHASHI
 
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
Mike Subelsky
 
Acceptance Testing with Webrat
Acceptance Testing with WebratAcceptance Testing with Webrat
Acceptance Testing with Webrat
Luismi Cavallé
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
stephskardal
 
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 prazos
Igor Sobreira
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialYi-Ting Cheng
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
Shumpei Shiraishi
 
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 - BrazilJS
Loiane 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" Domino
Rob 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 Framework
Dirk Haun
 

Similar to 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
 

Recently uploaded

An introduction to the cryptocurrency investment platform Binance Savings.
An introduction to the cryptocurrency investment platform Binance Savings.An introduction to the cryptocurrency investment platform Binance Savings.
An introduction to the cryptocurrency investment platform Binance Savings.
Any kyc Account
 
Mastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnapMastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnap
Norma Mushkat Gaffin
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
taqyed
 
Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...
Lviv Startup Club
 
The Influence of Marketing Strategy and Market Competition on Business Perfor...
The Influence of Marketing Strategy and Market Competition on Business Perfor...The Influence of Marketing Strategy and Market Competition on Business Perfor...
The Influence of Marketing Strategy and Market Competition on Business Perfor...
Adam Smith
 
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
SOFTTECHHUB
 
Auditing study material for b.com final year students
Auditing study material for b.com final year  studentsAuditing study material for b.com final year  students
Auditing study material for b.com final year students
narasimhamurthyh4
 
-- June 2024 is National Volunteer Month --
-- June 2024 is National Volunteer Month ---- June 2024 is National Volunteer Month --
-- June 2024 is National Volunteer Month --
NZSG
 
Sustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & EconomySustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & Economy
Operational Excellence Consulting
 
ikea_woodgreen_petscharity_dog-alogue_digital.pdf
ikea_woodgreen_petscharity_dog-alogue_digital.pdfikea_woodgreen_petscharity_dog-alogue_digital.pdf
ikea_woodgreen_petscharity_dog-alogue_digital.pdf
agatadrynko
 
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdf
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdfBài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdf
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdf
daothibichhang1
 
amptalk_RecruitingDeck_english_2024.06.05
amptalk_RecruitingDeck_english_2024.06.05amptalk_RecruitingDeck_english_2024.06.05
amptalk_RecruitingDeck_english_2024.06.05
marketing317746
 
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.docBài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
daothibichhang1
 
The effects of customers service quality and online reviews on customer loyal...
The effects of customers service quality and online reviews on customer loyal...The effects of customers service quality and online reviews on customer loyal...
The effects of customers service quality and online reviews on customer loyal...
balatucanapplelovely
 
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challengesEvent Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Holger Mueller
 
3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx
tanyjahb
 
LA HUG - Video Testimonials with Chynna Morgan - June 2024
LA HUG - Video Testimonials with Chynna Morgan - June 2024LA HUG - Video Testimonials with Chynna Morgan - June 2024
LA HUG - Video Testimonials with Chynna Morgan - June 2024
Lital Barkan
 
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
bosssp10
 
Premium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern BusinessesPremium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern Businesses
SynapseIndia
 
Buy Verified PayPal Account | Buy Google 5 Star Reviews
Buy Verified PayPal Account | Buy Google 5 Star ReviewsBuy Verified PayPal Account | Buy Google 5 Star Reviews
Buy Verified PayPal Account | Buy Google 5 Star Reviews
usawebmarket
 

Recently uploaded (20)

An introduction to the cryptocurrency investment platform Binance Savings.
An introduction to the cryptocurrency investment platform Binance Savings.An introduction to the cryptocurrency investment platform Binance Savings.
An introduction to the cryptocurrency investment platform Binance Savings.
 
Mastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnapMastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnap
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
 
Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...Kseniya Leshchenko: Shared development support service model as the way to ma...
Kseniya Leshchenko: Shared development support service model as the way to ma...
 
The Influence of Marketing Strategy and Market Competition on Business Perfor...
The Influence of Marketing Strategy and Market Competition on Business Perfor...The Influence of Marketing Strategy and Market Competition on Business Perfor...
The Influence of Marketing Strategy and Market Competition on Business Perfor...
 
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
 
Auditing study material for b.com final year students
Auditing study material for b.com final year  studentsAuditing study material for b.com final year  students
Auditing study material for b.com final year students
 
-- June 2024 is National Volunteer Month --
-- June 2024 is National Volunteer Month ---- June 2024 is National Volunteer Month --
-- June 2024 is National Volunteer Month --
 
Sustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & EconomySustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & Economy
 
ikea_woodgreen_petscharity_dog-alogue_digital.pdf
ikea_woodgreen_petscharity_dog-alogue_digital.pdfikea_woodgreen_petscharity_dog-alogue_digital.pdf
ikea_woodgreen_petscharity_dog-alogue_digital.pdf
 
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdf
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdfBài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdf
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc.pdf
 
amptalk_RecruitingDeck_english_2024.06.05
amptalk_RecruitingDeck_english_2024.06.05amptalk_RecruitingDeck_english_2024.06.05
amptalk_RecruitingDeck_english_2024.06.05
 
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.docBài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
 
The effects of customers service quality and online reviews on customer loyal...
The effects of customers service quality and online reviews on customer loyal...The effects of customers service quality and online reviews on customer loyal...
The effects of customers service quality and online reviews on customer loyal...
 
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challengesEvent Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
 
3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx
 
LA HUG - Video Testimonials with Chynna Morgan - June 2024
LA HUG - Video Testimonials with Chynna Morgan - June 2024LA HUG - Video Testimonials with Chynna Morgan - June 2024
LA HUG - Video Testimonials with Chynna Morgan - June 2024
 
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
 
Premium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern BusinessesPremium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern Businesses
 
Buy Verified PayPal Account | Buy Google 5 Star Reviews
Buy Verified PayPal Account | Buy Google 5 Star ReviewsBuy Verified PayPal Account | Buy Google 5 Star Reviews
Buy Verified PayPal Account | Buy Google 5 Star Reviews
 

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