JavaScript
  Home arrow JavaScript arrow Page 3 - Building an RTF-capable Form with the Ext ...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Building an RTF-capable Form with the Ext JS Framework
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2009-02-25

    Table of Contents:
  • Building an RTF-capable Form with the Ext JS Framework
  • Review: a multi-tabbed web form with the Ext JS framework
  • Adding an HTML editor to a multi-tabbed web form
  • The application’s complete source code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building an RTF-capable Form with the Ext JS Framework - Adding an HTML editor to a multi-tabbed web form


    (Page 3 of 4 )

    As I mentioned in the previous section, my purpose here is to demonstrate how to use the Ext JS library to build a multi-tabbed web form that also incorporates a useful HTML editor. To accomplish this task, again I’m going to use an instance of the “FormPanel” JavaScript class that you saw in the prior example, which also will include an HTML editing text box.

    Having explained that, please take a look at the following JavaScript snippet, which is tasked with rendering this multi-tabbed online form. Here it is:

    Ext.onReady(function(){

    Ext.QuickTips.init();

    var theform=new Ext.FormPanel({

    labelAlign: 'top',

    title: 'Inner Tabs',

    bodyStyle:'padding:5px',

    width: 600,

    items: [{

    layout:'column',

    border:false,

    items:[{

    columnWidth:.5,

    layout: 'form',

    border:false,

    items: [{

    xtype:'textfield',

    fieldLabel: 'First Name',

    name: 'first',

    anchor:'95%'

    }, {

    xtype:'textfield',

    fieldLabel: 'Company',

    name: 'company',

    anchor:'95%'

    }]

    },{

    columnWidth:.5,

    layout: 'form',

    border:false,

    items: [{

    xtype:'textfield',

    fieldLabel: 'Last Name',

    name: 'last',

    anchor:'95%'

    },{

    xtype:'textfield',

    fieldLabel: 'Email',

    name: 'email',

    vtype:'email',

    anchor:'95%'

    }]

    }]

    },{

    xtype:'tabpanel',

    plain:true,

    activeTab: 0,

    height:235,

    defaults:{bodyStyle:'padding:10px'},

    items:[{

    title:'Personal Information',

    layout:'form',

    defaults: {width: 230},

    defaultType: 'textfield',


    items: [{

    fieldLabel: 'First Name',

    name: 'first',

    allowBlank:false,

    value: 'Alejandro'

    },{

    fieldLabel: 'Last Name',

    name: 'last',

    value: 'Gervasio'

    },{

    fieldLabel: 'Company',

    name: 'company',

    value: 'Electrical Web'

    }, {

    fieldLabel: 'Email',

    name: 'email',

    vtype:'email'

    }]

    },{

    title:'Phone Numbers',

    layout:'form',

    defaults: {width: 230},

    defaultType: 'textfield',


    items: [{

    fieldLabel: 'Home',

    name: 'home',

    value: '(777) 555-1010'

    },{

    fieldLabel: 'Business',

    name: 'business'

    },{

    fieldLabel: 'Fax',

    name: 'fax'

    }]

    },{

    cls:'x-plain',

    title:'Comments',

    layout:'fit',

    items: {

    xtype:'htmleditor',

    id:'bio2',

    fieldLabel:'Comments'

    }

    }]

    }],


    buttons: [{

    text: 'Save'

    },{

    text: 'Cancel'

    }]

    });

    // display the form

    theform.render(document.body);

    });

     

    Undoubtedly, if you examine in detail the above JavaScript segment of code, you’ll have to agree with me that it’s pretty easy to follow. As you can see, in this case the web form is built by feeding the constructor of the “FormPanel” class the proper input parameters, which have been utilized in previous examples as well.

    However, apart from the aforementioned incoming arguments, you should pay attention to the JavaScript code that actually incorporates an HTML editor into the respective web form. Here’s where the magic happens:

    xtype:'htmleditor',


    Undeniably, the above JavaScript statement demonstrates in a nutshell the impressive capabilities of the Ext JS library, particularly when it comes to constructing dynamic user interfaces with minor efforts. As you can see in this specific case, this single parameter is enough to include a complete rich text editor into the online form being created. That’s pretty impressive, isn’t it?

    Of course, in order to complement the previous hands-on example, you’ll need to see how this multi-tabbed web form looks. Below I included a screen capture, which shows its visual appearance quite clearly:

     


    Well, now that you hopefully learned the basic concepts that surround the creation of a dynamic web form that incorporates some helpful text editing capabilities, by means of the Ext JS framework, it’s time to show the complete source code that corresponds to this web application, including all of the CSS and JavaScript dependencies required to make it work as expected.

    Therefore, in the concluding section of this tutorial, I’m going to embed all of the JavaScript code listed previously into a simple (X)HTML file. In this way you can have it available at one single place, in case  you want to introduce your own modifications.

    Please, go ahead and read the next few lines. We’re almost done!

    More JavaScript Articles
    More By Alejandro Gervasio


       · This last episode of the series demonstrates how to use the Ext JS library, this...
       · Thank you for this series articles.It was very useful !Cheers
       · Thanks for the kind words. Good to know my article has been useful to...
     

    JAVASCRIPT ARTICLES

    - Comparing Fields and Customizing Error Messa...
    - Checking Numbers and File Extensions with jQ...
    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek