Results 1 to 6 of 6

Thread: Designer 2 - Quick question

  1. #1
    Sencha User
    Join Date
    Dec 2008
    Posts
    85
    Vote Rating
    0
      0  

    Default 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 User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,487
    Vote Rating
    146
      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

  3. #3
    Sencha User
    Join Date
    Dec 2008
    Posts
    85
    Vote Rating
    0
      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,528
    Vote Rating
    353
      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 - 6
    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
      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,528
    Vote Rating
    353
      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 - 6
    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!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •