sebs 1 eval in jsObjects 0

I have replaced the first evals in jsObjects

that code
    eval(gridName + ".element = gridTable");    //element
    eval(gridName + ".createColumn = GridPubCreateColumn");    //method
    eval(gridName + ".createCell = GridPubCreateCell");    //method
    eval(gridName + ".createRow = GridPubCreateRow"); //method
    eval(gridName + ".editRow = GridPubEditRow"); //method
    eval(gridName + ".removeRow = GridPubRemoveRow"); //method
    eval(gridName + ".moveRow = GridPubMoveRow"); //method
    eval(gridName + ".newButton = GridPubNewButton"); //method
    eval(gridName + ".getGridData = GridPvtGetGridData"); //method
    eval(gridName + ".cellClick = doNothing");    //event
    eval(gridName + ".editDone = doNothing");    //event
    eval(gridName + ".deleteDone = doNothing"); //event
    eval(gridName + ".GridParent = gridParent");    //property
    eval(gridName + ".GridRowCount = 0");    //private property
    eval(gridName + ".CurrentCell = ''");    //private property
    eval(gridName + ".currentRow = ''");    //public property
    eval(gridName + ".rootDir = rootDir");    //private property
    eval(gridName + ".id = gridName");    //private property
    eval(gridName + ".textChecker = null"); //public property
    eval(gridName + ".readOnly = false");    //private property
    eval("tbObject = " + gridName);    //assignment

became


    var tbObject = {
        element:         gridTable,
        createColumn:    GridPubCreateColumn,
        createCell:        GridPubCreateCell,
        createRow:        GridPubCreateRow,
        removeRow:         GridPubRemoveRow,
        moveRow:         GridPubMoveRow,
        newButton:         GridPubNewButton,
        getGridData:    GridPvtGetGridData,
        cellClick:         doNothing,
        editDone:         doNothing,
        deleteDone:     doNothing,
        GridParent:        gridParent,
        GridRowCount:    0,
        CurrentCell:    '',
        currentRell:    '',
        rootDir:        rootDir,
        id:                gridName,
        textChecker:    null,
        readOnly:        false
    };

;))))

I guess i will have to replace a lot of the code, just for optimization issues ;)
Related Entries:
pnajax with json further developments
foxy web developer toolbox
anatomy of an ajax request
everthing new
talk at xtech
 Permalink

anatomy of an ajax request

What is happening ona Ajax request and how we have to react on that what happens:

Pre Request
Previous to the request we need to instanciate the ajax framework and load all classes.

Firing the request
We need to tell the gui NOT to handle additional clicks for specific parts of the gui, since it could be possible taht a dom id is missing that is needed by the later dom wirte stuff that happens when you server has performed the action and returned a result. Since you can not be sure that the gui is in the same state and you can not make a

var result = myajaxfunc();

just because of the asyncronous nature of the whole thing. There is need for the information what part of teh gui should be blocked, aka event-cancelled

Working with the results data
OK its starting to get a bit tricky, now were in the real events of that ajax request. Since we are doing Async (the A in Ajax) data retrieval, its not possible to do (cant stress this enough)

var result = myajaxfunc();

So you have to use the abillity of javascript to tell it which function name it should use, or which anonymous function i pass. So (simple) the above example gets

var func_result = function (return) {
// domesomething withmyresult
}

myajaxfunc(func_result);

Oops a error occured
Various errors can happen:

- postnuke function does return errormsg
- request status is not 200
- malformed data
- unknown postnuke function called

The first 3 need to be handeled, for the fourth pnAjax will have a re-written pnmodapifunc method, that will NOT return a error page when you call a unknown function (are we java or what ?, who did this .. i dont get it till today, i guess ill need to get my german sheppards on this guy ... wot kind of system design is tis ?) .... anyway .. in a stack of 10 funcs all these errors can occur and need to be handeled ....

Finalizing the thing
If you called 10 Postnuke functions you might need som post processing, that takes polace in the on finalize handler ;) You can gather the results here (like for example getting the products of categorie dogs and birds), match the together and stick them into the pn datagrid ;)

Related Entries:
sebs 1 eval in jsObjects 0
pnajax with json further developments
everthing new
foxy web developer toolbox
talk at xtech
 Permalink

pnajax with json further developments

With a little help from e-voc i made the json serializer work.
No well go soon to be async and the all will be much better.

Besides i started work hard on the integration of jsobjects. I guess ill have to rewrite some of the code to make it work w.o. evil eval.
The grid example is still simple, dropping notices etc .. but the api is growing. I dont have this much time, bus as ill make pnAjax a important component on the pncommerce project, reusing the grid and the tree for basic gui layout, it will get a lot of commits anyway.

The big Ajax discussion has come in place to postnuke. Again it looks like writing down things, instead of write code in the first blink of an idea is considered to be a bad thing there. Markwest requested a unified ajax Project for the postnukeworld, but i guess that will not take place .. why ?

The Approaches are too different

Chestnuts Ajax example is
- not using serialization
- relies on handcoded servers
- has no framework components
- has no event model catching errors from the serverside

Frank Schummertz pnForum Stuff:
- is using AHAH data (returning HTML instead of XML or serialized data
- relies on handcoded servers
- has no framework components
- has no event model catching errors from the serverside

pnAjax
- uses json data serialization
- has a tested gui kit / framework
- relies on no handcoded server to use ajax funcs on the client
- has a event model catching errors from the serverside

Anyway, i am really opposing doing 3 times the same work, but as i see from the mailing list postings, there is a request for a lot of functionality that is already in pnAJax. So i guess it was worth the time to sit down and thing of a framework that can totally integrate with postnuke instead of building stuff on top, that might be sexy, but is ugly code.

You migth call me a thread , but if there is no movement twoards a performant approach for the data stuff and nothing more that, hey, integrate scriptacolous into postnuke, Ill not be the one to jump in and make the lead on such a project .. ill guess it takes a year to explain to others what they need to develop .... pnAjax is rather complex on the code side of the project development ... but easy to use for the final developer, implementing his own apps with just a buch of loc.
Related Entries:
sebs 1 eval in jsObjects 0
PHP Unit Test Systems at GSOC
beating dead smarty horses
doxygen for eclipse
Zend Framework Rest Server II - Return of the Characters
Comments (4)  Permalink
1-3/3