1. #1
    Sencha User
    Join Date
    Dec 2008
    Posts
    85
    Vote Rating
    0
    martinrame is on a distinguished road

      0  

    Default Designer 2 - Quick question

    Designer 2 - Quick question


    I'm testing Designer 2 and have two questions.

    1 - In my application.js I have a singleton that stores application configuration, like this:

    Code:
    Ext.define('Globals',{
      singleton: true,
      loggedIn: false  
    });
    So far, I'm starting my app with a custom "app.js", because Designer overwrites my file removing my Ext.define. How/where can I add this code to my app in Designer?.

    2 - In my app, I only want to declare Controllers in the main app file, but Designer adds Stores, Views and Models automatically. How can I force Designer to only add Controllers?.

    Thanks in advance,
    Leonardo.

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,188
    Vote Rating
    119
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    1) You can put this inside your launch method of the application. Double click on the Application node (or click on the application and go to the code view). Then use the drop down in the top left to switch to the launch method.

    2) This is currently by design. Are you putting the stores/views/models on a different controller other than the application controller? If so the designer should prompt you to remove it from Application when you add it to the controller.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    Dec 2008
    Posts
    85
    Vote Rating
    0
    martinrame is on a distinguished road

      0  

    Default


    Thanks aconran, I solved question #2.

    Regarding #1, I added a model named "User" and created an instance in app launch as follows:

    Code:
        launch: function() {
            var userInstance = Ext.create('MyApp.model.User', {loggedIn: false});
        }
    The problem is that I need to access this instance from a controller (also defined in app.js). In the controller's init function I added this:

    Code:
    userInstance.set('loggedIn', false);
    But I get "Uncaught ReferenceError: userInstance is not defined" in my browser javascript debug window.

    Leonardo.

  4. #4
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,264
    Vote Rating
    80
    ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough

      0  

    Default


    Put the value in your singleton:

    Code:
    Ext.define('Globals',{  singleton: true,  loggedIn: false  });
    var Globals = MyApp.Globals;
    Code:
    launch: function() {        
    Globals.user = Ext.create('MyApp.model.User', {loggedIn: false});    
    }
    Then access the object using Globals.user
    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!

  5. #5
    Sencha User
    Join Date
    Dec 2008
    Posts
    85
    Vote Rating
    0
    martinrame is on a distinguished road

      0  

    Default


    ssamayoa, this is my app.js, where should I add my singleton?

    Code:
    Ext.Loader.setConfig({    
     enabled: true
    });
    
    
    Ext.application({
        autoCreateViewport: true,
    
    
        name: 'MyApp',
    
    
        controllers: [
            'MyForm',
            'MyGridPanel',
            'ViewportController'
        ],
    
    
        launch: function() {
        }
    });

  6. #6
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,264
    Vote Rating
    80
    ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough

      0  

    Default


    I just check designer and doesnt have a "requires" property.

    I use that technique with hand chafted app.js, something like:

    Code:
    Ext.application({
        autoCreateViewport: true,
        name: 'MyApp',
    	requires : [ 'Globals'], // <<<--here
        launch: function() {
    		Globals.user...
        }
    });
    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!

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi