Hybrid View

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha Premium Member
    Join Date
    Jan 2011
    Location
    London, UK
    Posts
    50
    Vote Rating
    2
    welshcathy is on a distinguished road

      0  

    Default [1.1.0] Ext.regApplication is not compatible with application profiles

    [1.1.0] Ext.regApplication is not compatible with application profiles


    If you are using application profiles and Ext.regApplication there is a bug in Ext.Contoller.render()...
    The bug is in setting a local variable profile as either the current profile string or the current application instance.
    It then calls profile.getRenderTarget() which will obviously fail when the profile is set to a string!

    See attached code (renamed to .js.txt for the uploader) for an example of the bug.

    Work around if you still want to use profiles, use either:

    Code:
    MyApp = new Ext.Application({ ... });
    or
    Code:
    MyAppDefinition = Ext.extend(Ext.Application, { ... });
    MyApp = new MyAppDefinition();
    Cheers,

    Cathy

    bug.js.txt

  2. #2
    Sencha User SpyKeey's Avatar
    Join Date
    Oct 2011
    Location
    Iasi, Romania
    Posts
    8
    Vote Rating
    0
    SpyKeey is on a distinguished road

      0  

    Default


    Hello,

    I have the same problem and I'm interested to know if there is any solution to keep the "Ext.regApplication" (for MVC) and still use "profiles:".

    If I use any of your suggestions (new Ext.Application - or - Ext.extend(Ext.Application...)) then I will not be able to keep the current MVC structure of the application since I get the following error:

    "Uncaught TypeError: Cannot read property 'viewport' of undefined"

    I guess this means my viewport is not visible in Controllers anymore.

    Thanks,

  3. #3
    Sencha Premium Member
    Join Date
    Jan 2011
    Location
    London, UK
    Posts
    50
    Vote Rating
    2
    welshcathy is on a distinguished road

      0  

    Default


    It's the controller that is missing a reference to the app.

    You set it manually as follows:

    In the Application
    Code:
        launch: function() {
    
    
    		// load styles by device
    		Ext.Mobile.loadDeviceStylesheet('aps','pth');
        	Ext.Mobile.log('app launched ... ');
    		
    		Ext.dispatch({
    			controller: 'MainController',
    			action: 'doLaunch',
    			app: this
    		});  		
        	
        },
    Then in the Controller method
    Code:
        doLaunch: function(params){
    
    
        	// set up reference to application since we can't use regApplication
        	this.app = params.app;    
     	
           // etc etc ....
                	
        },

  4. #4
    Sencha User SpyKeey's Avatar
    Join Date
    Oct 2011
    Location
    Iasi, Romania
    Posts
    8
    Vote Rating
    0
    SpyKeey is on a distinguished road

      0  

    Default Detailed project structure

    Detailed project structure


    Hello Cathy,

    I tried the solution you suggested but I get the same error, maybe is something that I'm doing wrong or maybe my application structure is different, here you may see it:

    File: App.js
    Code:
    Ext.regApplication({
      name: 'MyApp',
      defaultUrl: 'Home/index',
    
    
      launch: function()
      {
        // Init the Viewport
        this.viewport = new MyApp.views.Viewport();
      }, 
      
      profiles: {
        portraitPhone: function() {
          return Ext.is.Phone && Ext.orientation == 'portrait';
        },
        landscapePhone: function() {
          return Ext.is.Phone && Ext.orientation == 'landscape';
        },
        portraitTablet: function() {
          return !Ext.is.Phone && Ext.orientation == 'portrait';
        },
        landscapeTablet: function() {
          return !Ext.is.Phone && Ext.orientation == 'landscape';
        }
      }
    });
    File: HomeController.js
    Code:
    Ext.regController('Home', {
      // Index action
      index: function(options) {
        if (!this.indexView) {
          this.indexView = this.render({
            xtype: 'HomeIndex'
          });
        }
         
        this.application.viewport.setActiveItem(this.indexView, options.animation);
      }  
    });
    I have changed in "App.js" the "Ext.regApplication" to "new Ext.Application" and added your code to "launch:" (of course changing the controller name).

    Then, in "HomeController.js" I have added your code for "doLaunch" and I still get the same error after I access the application in Google Chrome:

    Uncaught TypeError: Cannot read property 'viewport' of undefined (HomeController.js:10)

    This line here:
    Code:
    this.application.viewport.setActiveItem(this.indexView, options.animation);

  5. #5
    Sencha Premium Member
    Join Date
    Jan 2011
    Location
    London, UK
    Posts
    50
    Vote Rating
    2
    welshcathy is on a distinguished road

      0  

    Default


    Hiya,

    Try changing theses lines in the controller doLaunch method
    Code:
    // set up reference to application since we can't use regApplication
    this.app = params.app;
    to
    Code:
    // set up reference to application since we can't use regApplication
    this.application = params.app;
    You can see in the error message you get that in the Controller (this) it is failing to find a reference to this.application not this.app as I had in my snippet.

    Hint - in Chrome debugger in the Script panel you can set a break point to trigger before an exception is thrown - allowing you to inspect the relevant objects.
    http://code.google.com/chrome/devtools/docs/scripts-breakpoints.html#js_exceptions

    G
    ood luck!

    Cathy

  6. #6
    Sencha User SpyKeey's Avatar
    Join Date
    Oct 2011
    Location
    Iasi, Romania
    Posts
    8
    Vote Rating
    0
    SpyKeey is on a distinguished road

      0  

    Default Hey Cathy

    Hey Cathy


    Hey Cathy,

    Thanks for your time, help and hint. I will give it a shot later this afternoon and I will let you know if it works.

    Thank you again for your time,

    Luigi,

  7. #7
    Sencha User
    Join Date
    Mar 2012
    Posts
    7
    Vote Rating
    0
    antiplaka is on a distinguished road

      0  

    Default


    Quote Originally Posted by welshcathy View Post
    It's the controller that is missing a reference to the app.
    I suspect that other controllers will miss the reference too?

  8. #8
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    San Antonio, TX
    Posts
    93
    Vote Rating
    0
    jnotti is on a distinguished road

      0  

    Default


    There is no update, I believe this was abandoned in favor of ST2 which btw does not implement setProfile. You really need to roll your own solution with this. I'd recommend that you go the route of ST2 which handles the orientation change better. See: http://www.sencha.com/forum/showthre...ntation-Change

  9. #9
    Sencha User
    Join Date
    Mar 2012
    Posts
    7
    Vote Rating
    0
    antiplaka is on a distinguished road

      0  

    Default


    Thank you jnotti, i believe you are right and 1.x branch is abandoned.