SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAIGetting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAITim Wilson
 
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptxQSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptxDitasDelaCruz
 
Paradip CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Paradip CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGParadip CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Paradip CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGpr788182
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with CultureSeta Wicaksana
 
Arti Languages Pre Seed Teaser Deck 2024.pdf
Arti Languages Pre Seed Teaser Deck 2024.pdfArti Languages Pre Seed Teaser Deck 2024.pdf
Arti Languages Pre Seed Teaser Deck 2024.pdfwill854175
 
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service AvailableNashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Availablepr788182
 
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
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...daisycvs
 
Cannabis Legalization World Map: 2024 Updated
Cannabis Legalization World Map: 2024 UpdatedCannabis Legalization World Map: 2024 Updated
Cannabis Legalization World Map: 2024 UpdatedCannaBusinessPlans
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPanhandleOilandGas
 
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Adnet Communications
 
UAE Bur Dubai Call Girls ☏ 0564401582 Call Girl in Bur Dubai
UAE Bur Dubai Call Girls ☏ 0564401582 Call Girl in Bur DubaiUAE Bur Dubai Call Girls ☏ 0564401582 Call Girl in Bur Dubai
UAE Bur Dubai Call Girls ☏ 0564401582 Call Girl in Bur Dubaijaehdlyzca
 
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...pujan9679
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxCynthia Clay
 
joint cost.pptx COST ACCOUNTING Sixteenth Edition ...
joint cost.pptx  COST ACCOUNTING  Sixteenth Edition                          ...joint cost.pptx  COST ACCOUNTING  Sixteenth Edition                          ...
joint cost.pptx COST ACCOUNTING Sixteenth Edition ...NadhimTaha
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityEric T. Tung
 
Jual Obat Aborsi ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan Cytotec
Jual Obat Aborsi ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan CytotecJual Obat Aborsi ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan Cytotec
Jual Obat Aborsi ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan CytotecZurliaSoop
 
Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...
Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...
Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...meghakumariji156
 

Kürzlich hochgeladen (20)

Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAIGetting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
 
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptxQSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
 
Paradip CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Paradip CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGParadip CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Paradip CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 
Arti Languages Pre Seed Teaser Deck 2024.pdf
Arti Languages Pre Seed Teaser Deck 2024.pdfArti Languages Pre Seed Teaser Deck 2024.pdf
Arti Languages Pre Seed Teaser Deck 2024.pdf
 
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service AvailableNashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
 
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
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
 
Cannabis Legalization World Map: 2024 Updated
Cannabis Legalization World Map: 2024 UpdatedCannabis Legalization World Map: 2024 Updated
Cannabis Legalization World Map: 2024 Updated
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation Final
 
HomeRoots Pitch Deck | Investor Insights | April 2024
HomeRoots Pitch Deck | Investor Insights | April 2024HomeRoots Pitch Deck | Investor Insights | April 2024
HomeRoots Pitch Deck | Investor Insights | April 2024
 
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
 
UAE Bur Dubai Call Girls ☏ 0564401582 Call Girl in Bur Dubai
UAE Bur Dubai Call Girls ☏ 0564401582 Call Girl in Bur DubaiUAE Bur Dubai Call Girls ☏ 0564401582 Call Girl in Bur Dubai
UAE Bur Dubai Call Girls ☏ 0564401582 Call Girl in Bur Dubai
 
Buy gmail accounts.pdf buy Old Gmail Accounts
Buy gmail accounts.pdf buy Old Gmail AccountsBuy gmail accounts.pdf buy Old Gmail Accounts
Buy gmail accounts.pdf buy Old Gmail Accounts
 
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptx
 
joint cost.pptx COST ACCOUNTING Sixteenth Edition ...
joint cost.pptx  COST ACCOUNTING  Sixteenth Edition                          ...joint cost.pptx  COST ACCOUNTING  Sixteenth Edition                          ...
joint cost.pptx COST ACCOUNTING Sixteenth Edition ...
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League City
 
Jual Obat Aborsi ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan Cytotec
Jual Obat Aborsi ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan CytotecJual Obat Aborsi ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan Cytotec
Jual Obat Aborsi ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan Cytotec
 
Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...
Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...
Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...
 

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