1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    11
    Vote Rating
    0
    ThaDafinser is on a distinguished road

      0  

    Default Generating extJS in backend or better not?

    Generating extJS in backend or better not?


    Hello,

    currently i'm thinking about switching from jQueryUI to extJS.

    Currently all grids, forms and other elements, are directly created in my backend (the javascript function calling + json code).

    For sure i've seperated javascript abstraction classes, that i only have to call the needed functions to render a grid or a form. (so i never need eval() or have to respond javascript blocks to execute)

    The good thing is now: I only have to change my abstraction classes for each element and i can switch the javascript library.


    But is this approach also fine with extJS? Or is it better to create seperate JS files for each grid/form?!?

    By the way:
    I don't create a "websites".
    It's an application there 90% of the pages are out of form and grids......(like every application)

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,154
    Vote Rating
    475
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    This is certainly possible, but I have never performed this myself.
    I prefer to use the client side approach for development and combine to 1 file on deploy.

    There are numerous threads regarding your approach in the forums for reference.
    ( using json for component config / defaults using applyIf )

    Regards,
    Scott.

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    11
    Vote Rating
    0
    ThaDafinser is on a distinguished road

      0  

    Default


    Okay, then i will do it this way.

    The benefits for me are:
    - if you got a bug -> you have to fix it in one class
    - if you wand to upgrade the library -> you have to fix it in one class
    - if you add a new feature -> you have to add it in one class
    ....

    Thx.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,050
    Vote Rating
    657
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    I'd say all those benefits are bogus.

    Let's assume you generating the UI via the backend. You're still going to have several tiers in your application, data, business logic, presentation.

    If you need to fix a bug affecting the UI, you need to fix it in the UI layer (server or client).
    If you want to upgrade the UI library, you need to upgrade the UI library (server or client).
    If you need to add a feature, you need to add it in the data/business layer & the UI layer.

    Certainly it can make sense to send some kind of configuration options from the server, but trying to build your whole UI on the server and generate client code isn't a great idea, why not just write it in the client directly?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User
    Join Date
    Jun 2012
    Posts
    11
    Vote Rating
    0
    ThaDafinser is on a distinguished road

      0  

    Default


    I think you missunderstood me...

    There are abstraction classes for grids, forms, ....directy in javascript.

    I return a JSON object after each request, which has configs and function calls for this classes.


    But i cannot write pure hard written javascript for each form, grid, ...this would kill me

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,050
    Vote Rating
    657
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    No, I understand what you're saying, it just doesn't seem like a good idea.

    Also, you can't specify functions in JSON (you can if you use eval, but not if you plan to using JSON.parse).
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  7. #7
    Sencha User
    Join Date
    Jun 2012
    Posts
    11
    Vote Rating
    0
    ThaDafinser is on a distinguished road

      0  

    Default


    Currently i use "apply" for function calling.

    And in the case of a "new" function (complete script block). I create a scriptblock in HTML....instead of eval()
    Code:
    add : function(text) {
            if (text !== undefined) {
                var codeBlock = document.createElement('script');
                codeBlock.type = 'text/javascript';
                codeBlock.text = text;
    
    
                document.getElementById('scriptBlock').appendChild(codeBlock);
            }
        }
    The last one is a bad approach. But i didn't needed it often. When you need a function often, you can move it to the static javascript. and then only call the function.


    Edit:
    You just have to split the different parts in JSON object.
    Then you can use "JSON.parse" for the right parts....

  8. #8
    Sencha User
    Join Date
    Jun 2012
    Posts
    11
    Vote Rating
    0
    ThaDafinser is on a distinguished road

      0  

    Default


    I found now a good example of what i'm talking about.
    In the blog there are a couple of examples, which i will take as a basis.

    http://aboutfrontend.com/extjs/extde...end-framework/

  9. #9
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    941
    Vote Rating
    65
    westy is just really nice westy is just really nice westy is just really nice westy is just really nice

      0  

    Default


    We certainly generate some client-side classes from server-side definitions, but only for some things, specifically entities.

    Things like simple models and stores get spat out (that wire up to web services), and some configuration panels too.

    Works well for simplistic entities, and panels to add/edit them. If any modification is needed an empty class that inherits from the generated one is produced that can be modified as needed.

    I would never attempt it for anything complex though, keep it simple and it can save time though, especially with suitable intermediate base classes or mixins setup to accomplish common tasks.
    Product Architect
    Altus Ltd.