Hi,

just for a matter of fun and to get some practice, I would like to
write a
small plugin for Web2py that should make Extjs development easier.

My main goals are:
- keep it simple
- keep it generic so that the same structure may be reused
in the future for other JS framework (Extjs is not free for all
purposes).
Anyway I do not trust libraries that completely hide what is below.
I am thinking more to a "nude look" where if you write some code
for Extjs, you can adapt your code to another target without rewriting
everything
- reuse Web2py objects and style (e.g. Rows and Field)

After some tests I see now three possible approaches and I would
like some opinions about.

1) Develop a widgets library
Web2py UI is based on the hierarchy from XmlComponent. The idea
is to create new classes that generate html/js code for the different
Extjs widgets

Example:
def grid():
    return dict(_html=jGRID(jSTORAGE(db().select(db.test.ALL) ),
                          jCOLUMN('stringa', db.test.stringf),
                          jCOLUMN('boolean', db.test.booleanf),
                          jCOLUMN('password', db.test.passwordf),
                          jCOLUMN('int', db.test.integerf),
                          jPAGINGTOOLBAR(),
                           title='test', height=300))

Adv/Cons
+ the widgets can be reused for other JS frameworks. What would change
is the parameters.
- requires the users to learn new classes (even though not too many)
- the code partially depends on the JS framework below


2) Develop a transformation tool for Web2py classes
The idea is to have a special construct, lets call it jS, that applies
Extjs feature to Web2py HTML
classes. Extjs provides the 'applyTo feature' that allows to reuse
existing markup for

Example:
def grid():
     return dict(_html = jS(
                                    FORM(
                                        INPUT(_type="text",
_name="test"),
                                    ))

Adv/Cons
+ reuse Web2py classes and html markup
+ generated code can partially work on browser with no js enabled
+ generated code is (maybe) more readable for people with little Extjs
experience
- I guess (but maybe someone can confirm) that 'applyTo' has some
limitations (e.g. it is not possible
  to define a field label in pure HTML)
- other JS framework does not support 'applyTo'. So even though the
code is really independent from extjs,
  in practice usage of other JS Fw may be difficult.


3) Develop a wrapper interface to Extjs.
The idea is to provide really a few classes that converts python dict/
parameters to extjs config objects.

Something like this...
http://www.extjs.com/blog/2009/09/30/ext-js-on-rails-a-comprehensivetutorial/

Adv/Cons
+ simple implementation
+ very strong control on the
- totally coupled with Extjs; no room for other JS Fw

Example:
def grid():
    return jWidget(DIV(id='myid'),
                        xtype='panel',
                        title='Auto-generated Ext.Panel!',
                        renderTo='myid',
                        frame=True,
                        width=300,
                        height=100,
                        html='Why are my feet so far from my head?',
                        buttons = [
                            dict(text='Save', iconCls='silk-disk'),
                            dict(text='Cancel', iconCls='silk-
cancel')])

Any contribute will be precious.

Luz

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to