Learning Ext JS 3

What are the adapters? What are the benefits of using them? Más videos

Descripción del tema

The Adapter pattern is used to allow classes to work together when normally could not because of incompatible interfaces, by providing its interface to clients while using the original interface.

Libraries

We can be thankful that Ext JS was created as an extension to the library YUI and because its structure is well designed; because of this we can execute Ext JS over other libraries without a problem. The implementations that now exist of this pattern (Adapter) are actually for the jQuery library, Prototype and YUI, also Ext JS has its own library which is called Ext-base. We can find the adapters in the following path ext-2.2/adapter.

Installation

To install one of these libraries we need to import it to the document immediately after importing the adapter and at the end, we need to import the Ext JS framework. Here's an example on how to install jQuery.
<script type="text/javascript" src="../ext-2.2/adapter/jquery/jquery.js"></script>
<script type="text/javascript" src="../ext-2.2/adapter/jquery/ext-jquery-adapter.js"></script>
<script type="text/javascript" src="../ext-2.2/ext-all.js"></script>
Even though we can use any of the libraries we talked about before, we can only have one Adapter "linked" to a library.

Tests

To test if the jQuery library has been installed successfully we need to write jQuery code and execute it. We can test the jQuery installation when we change the event onReady of Ext JS following the jQuery style.
$(function(){
         $(document.body).css('background-color','#ccc');
         var win = new Ext.Window({
                   title:'Hello world',
                   width:400,
                   height:300,
                   minimizable:true,
                   maximizable:true
         });
         win.show();
});
One more test you can do is to change the background color of the body. You can do this with jQuery very easy, you just need to add the following line inside the event ready.
$(document.body).css('background-color','#333');

Conclusions

As you can see, it is very easy to install libraries that we want to use and we won't see any difference because Ext JS behavior will be the same with any of these libraries. During the rest of the course we will use the library Ext-base, since is the Ext JS owns library, but everyone can use the library of your choice or the best you know.

Te gustaría recibir más tutoriales como este en tu correo?

Este tutorial pertenece al curso Learning Ext JS 3, te recomiendo revises el resto de los tutoriales ya que están en secuencia de menor a mayor complejidad.

Si deseas recibir más tutoriales como este en tu correo te recomiendo registrarte al curso, si ya eres miembro solo identifícate y registrate al curso, si no eres miembro te puedes registrar gratuitamente!

Si no gustas registrarte en este momento no es necesario! Aún así puedes recibir los nuevos tutoriales en tu correo! Jamás te enviaremos Spam y puedes cancelar tu suscripción en cualquier momento.

¿Olvidaste tu contraseña?

4Comentarios

  • Avatar-3 Jon 14/01/2010

    I have been using EXT Js for a while and am not sure what you mean by the adapter pattern. If you could put more detail in your post, i.e What the adapter pattern is and how its used by the Ext Js library it would be a useful read!

    • Avatar-10 Tereza 18/02/2010

      As Jon wrote on 1.14.10, I would like to know: (1) if I wish to use TWO libraries, e.g., jQuery and Prototype, would that be possible? (2) As I understand what you wrote, I could only apply one adapter to each of the two libraries; only one adapter can be used for jQuery and only one adapter can with Prototype. (3) Also, could you let me know if these adapters will still work with the new 3.0 release(s)?

      • Avatar-12 Crysfel 19/02/2010

        Hi Tereza. <strong>(1) if I wish to use TWO libraries, e.g., jQuery and Prototype, would that be possible?</strong> Yes! you can use anything you like. <strong>(2) As I understand what you wrote, I could only apply one adapter to each of the two libraries; only one adapter can be used for jQuery and only one adapter can with Prototype. </strong> Thats true, you can use the jQuery adapter and also import any other library such as prototype, mootools, jQuery and so on. <strong>(3) Also, could you let me know if these adapters will still work with the new 3.0 release(s)?</strong> of course! :)

        • Avatar-4 Nokrosis 05/11/2010

          Is there any performance difference between Ext-base vs any other adapter?

          Instructor del curso

          Crysfel3

          Autor: Crysfel Villa

          Software engineer with more than 7 years of experience in web development.

          Descarga Código Fuente Ver Demostración

          Regístrate a este curso

          Este tutorial pertenece al curso Learning Ext JS 3, revisa todos los tutoriales que tenemos en este mismo curso ya que están en secuencia y van de lo más sencillo a lo más complicado.

          Tendrás acceso a descargar los videos, códigos y material adicional.

          Podrás resolver los ejercicios incluidos en el curso así como los Quizzes.

          Llevarás un registro de tu avance.