Building ExtJs Widgets in Smalltalk
January 22, 2011
The image above shows an ExtJs text window created with 12 lines of Smalltalk code.
There are several ways to build ExtJs widgets. My preferred pattern is to create a configuration object and send it to the “ComponentMgr” to perform the actual instantiation.
Here are the 12 lines of Smalltalk code that produced the text window example above:
| d1 d2 |
d1 := Dictionary new.
d1 at: 'xtype' put: 'textarea'.
d2 := Dictionary new.
d2 at: 'xtype' put: 'window'.
d2 at: 'layout' put: 'fit'.
d2 at: 'initHidden' put: false.
d2 at: 'items' put: d1.
d2 at: 'width' put: 425.
d2 at: 'height' put: 375.
ComponentMgr create: d2
You can copy the above code into the workspace, highlight it, and “PrintIt” – a new text window should open.
ExtJs runs in all popular browsers including older versions without requiring any plug-ins. I have successfully used it on IE6 running on Windows 2000 behind a corporate firewall without a problem. It is, however, rather large (~650 kb) so smaller libraries could be better for lightweight applications (eg phones or clients with slow connections).