1. #11
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,324
    Vote Rating
    198
    ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold

      0  

    Default


    Quote Originally Posted by zouzhijun View Post
    Architect is functional for big app development now, but I found that Ext's localization support is not so good
    Instantiate the views from "owning" controller and use some sort of localizer like the one I posted here a few weeks ago.

    For example, from a event on some controller (button click) you normally instantiate the view the show it:

    PHP Code:
    onButtonClick: function(button) {
        
    Ext.widget("somewindow").show();
        
    // Call Localizer...

    But imagine that you have to instantiate the same window from different places over the whole application. Worst, you need to set some values (current employee, secutiry constraints, etc.) at view ir controller level before view is shown. You copy over and over the same code.

    So the best practice (at least for me) is to instantiate the view from the controller:

    PHP Code:
    onButtonClick: function(button) {
        
    this.getController("SomeController").show(someParams...);

    Controller:
    PHP Code:
    show: function(someParams...) {
        var 
    me thiswin Ext.widget("somewindow");
        
    // Set up win/controller accorting to operational params and/or context
        
    me.getSomeControl().setVisible(...);
        ...
        
    // Localize the window
        
    Localizer.localize(win);
        
    // Show
        
    win.show();

    I just figure out this way of doing things and, not much a surprise, someone in stackoverflow suggested this way back in november!

    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  2. #12
    Sencha User thesilentman's Avatar
    Join Date
    Apr 2007
    Location
    Athens, Greece
    Posts
    232
    Vote Rating
    2
    thesilentman is on a distinguished road

      0  

    Default


    Hi @ssamayoa,

    thanks for your feedback, yes that's how I ended up doing things, but it's not the right thing to do.
    I mean, spending time to find workarounds because the tool doesn't support what the framework provides.

    Cheers,
    Frank


    Quote Originally Posted by ssamayoa View Post
    Depending on the context you can set those values in controller events.

    For example, I have a window which must show/hide or change labels and so on components depending on user rights or current task. I use the beforeRender event to set them and in some cases the window's controller haves a method "show()" which instantiates the view and changes whatever is needed then show the view.

    Regards.

  3. #13
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,324
    Vote Rating
    198
    ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold

      0  

    Default


    Quote Originally Posted by thesilentman View Post
    I mean, spending time to find workarounds because the tool doesn't support what the framework provides.
    Yes and no.

    Tools are meant to ease tasks. The problem is that when you craft your applications by hand you can do whatever you want the way you want. But even with some limitations, what you need to develop is a new way of thinking in the context of the tool, I mean, SA.

    I HATE the code editor (I wish I could use eclipse to write it) but I save a lot of time with UI creation. I been working on one application (first real application with SA, 2d real application with ExtJS/MVC) for the last 2-3 months and while I sometimes I miss the freedom of hand crafted code (In mi first MVC application I used a lot of inheritance) now I can acomplish 99% of what I did before with SA + some tricks.

    Bottom line is: If something is to hard to accomplish, something smells bad there and you need to think different.

    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  4. #14
    Sencha User thesilentman's Avatar
    Join Date
    Apr 2007
    Location
    Athens, Greece
    Posts
    232
    Vote Rating
    2
    thesilentman is on a distinguished road

      0  

    Default


    I disagree on the smelling thing with you

    The problem of this specific thread for example, does not smell bad. Either does custom component integration smell bad. Mixins do not smell bad either.

    What I mean is, the things described above should be there to use in an easy manner. Not having to workaround using other parts of the framework.

    For example when I design an application where I can reuse a component more than once, I design that component and put all it's specific logic within the component, not having to assign an extra controller, like I have to do with this workaround...

    That way I can just extend it and reuse functionality without having to worry about having to code extra controller, etc....

    There is no bad smell in that. Actually that is how things should be, and what inheritance is all about. Code once, reuse, do not repeat yourself, because that makes your code prone to errors and also makes error fixing more difficult.

    As for the way of thinking, I agree we have to adjust on how the tool works, but only so far.
    It doesn't mean that we throw away proven development styles, even those propagated by extjs 4 itself.

    Cheers

  5. #15
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,324
    Vote Rating
    198
    ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold

      0  

    Default


    Quote Originally Posted by thesilentman View Post
    For example when I design an application where I can reuse a component more than once, I design that component and put all it's specific logic within the component, not having to assign an extra controller, like I have to do with this workaround...
    Agree, that's the part I miss the most.

    As I said, before SA I used inheritance a lot. Now I have templates (copy/paste) so bottom line I get duplicated code.

    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  6. #16
    Sencha User
    Join Date
    Apr 2010
    Posts
    4
    Vote Rating
    0
    zouzhijun is on a distinguished road

      0  

    Default


    Quote Originally Posted by thesilentman View Post

    What I mean is, the things described above should be there to use in an easy manner. Not having to workaround using other parts of the framework.
    I agree, same as I don't like something like "localize('win')" but prefer to using "'Some string'.translate()" as the posted link mentioned.。suppose the designer can support property value like 'foo'.bar(), we get it! That will be prefect!

    regards.

  7. #17
    Sencha Premium Member ethraza's Avatar
    Join Date
    Jun 2007
    Location
    Brazil
    Posts
    362
    Vote Rating
    3
    ethraza is on a distinguished road

      0  

    Default


    Hi.

    I come up with a similar but different approuch. What I'm doing is good for use variables as values for any property within Architect, even data on stores.It works for me because I have access to the scripts before it became evaluated JS in the browser, because I load the scripts via Ajax calls and evaluate then with script tags.
    So, for example, in the Architect, I set the "string" value as "EV(buttonText)".

    When I load a script that needs to be parsed, I use this:
    Code:
    sContent.replace(/[",']EV\(([^()]*)\)[",']/g, "$1");
    So, my JS will be translated, for example, like:
    text: "EV(buttonText)"
    will become
    text: buttonText
    with no quotes.

    Hope it help.
    LAMPE (Linux / Apache / MySQL / PHP / ExtJs)

  8. #18
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,324
    Vote Rating
    198
    ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold ssamayoa is a splendid one to behold

      0  

    Default


    because I load the scripts via Ajax calls and evaluate then with script tags
    What you mean?

    You aren't take advantage of dynamic class loading of ExtJS?
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  9. #19
    Sencha Premium Member ethraza's Avatar
    Join Date
    Jun 2007
    Location
    Brazil
    Posts
    362
    Vote Rating
    3
    ethraza is on a distinguished road

      0  

    Default


    No, because my code is ported from ExtJs 2 to 3 and 3 to 4. My system has a dynamic load scheme but one that I wrote myself back on ExtJs 2 times.
    Maybe in the future when I understand better the Architect and ExtJs 4, I can port that things.
    LAMPE (Linux / Apache / MySQL / PHP / ExtJs)