Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    19
    Vote Rating
    0
    tdekoekkoek is on a distinguished road

      0  

    Default Profile isActive is not taken into account

    Profile isActive is not taken into account


    I have created profiles as per the documentation (tablet and phone). If I create a profile and return false from the isActive method, the profile is still loaded and the views from that profile are displayed. Moreover, if I load multiple profiles and they all return false (meaning I wish for the default views to display), random profile views are used (sometimes tablet, sometimes phone.

  2. #2
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    18
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    Thank you for the report.

    Sencha Inc

    Jamie Avins

    @jamieavins

  3. #3
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    9
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    Loading all classes for all Profiles is actually the intended behavior - if we didn't do this then production builds would not work correctly. As it stands, a production build is a universal app - it works on all Profiles you have defined, without using dynamic loading in production.
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    19
    Vote Rating
    0
    tdekoekkoek is on a distinguished road

      0  

    Default


    I don't mind what it loads. I mind that isActive is not working. If isActive returns false, it should not be the active profile, so how is it that my view from that profile is being displayed?

  5. #5
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    9
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    The Profile itself doesn't determine which views your app instantiates. At some point your code must be calling something like Ext.create('MyApp.view.someProfile.someView') - the framework doesn't do that for you, it's all in the app itself.
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  6. #6
    Sencha User
    Join Date
    Jan 2012
    Posts
    19
    Vote Rating
    0
    tdekoekkoek is on a distinguished road

      0  

    Default


    Quote Originally Posted by edspencer View Post
    The Profile itself doesn't determine which views your app instantiates.
    According to the docs here: http://docs.sencha.com/touch/2-0/#!/guide/profiles, this does not seem to be correct:

    "Once the Profiles have been loaded, their isActive functions are called in turn. The first one to return true is the Profile that the Application will boot with" and "
    Now when we load the app on a phone, the Phone profile is activated and the application will load the following files:"

    Clearly the application is making the decision about which profiles to launch. In our application our views are being autocreated via their xtype as such:

    this.getNav().push(
    {
    xtype: 'vehicleDetail'
    }
    );

    If I have profiles defined in my application controller: profiles: ['Tablet', 'Phone'], then the above code AUTOMATICALLY creates a view from one of the profiles, even though both profiles are marked as inActive. If I remove the profile declaration, then the default views are created.

  7. #7
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    9
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    Ah - sounds like you're registering the same xtype for both the Phone and Tablet profiles, is that correct? That's one are where our guidance could be better - in general that pattern is not a good one as it makes the xtype mapping potentially nondeterministic. I would suggest you use unique xtypes for every component (even if it's just a Profile-specific variant) until we figure out a more elegant solution to this
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  8. #8
    Sencha User
    Join Date
    Jan 2012
    Posts
    19
    Vote Rating
    0
    tdekoekkoek is on a distinguished road

      0  

    Default


    Yes, that was it. I had multiple views with the same xtype. My mistake. So what I did was implement my own "View Factory", using the current active profile, something like:

    createView: function (viewName, profile) {
    var view = null;
    if (profile)
    view = Ext.create('App.view.' + profile._namespace + '.' + viewName);
    else
    view = Ext.create('App.view.' + viewName);
    return view;
    },
    getView: function (className) {
    var profile = this.getApplication().getCurrentProfile();
    var views = profile.getViews();
    if (views.indexOf(className) > -1)
    return this.createView(className, profile);
    else
    return this.createView(className);
    },
    pushView: function (className, title) {
    var view = this.getView(className);
    var nav = this.getNav();
    nav.push(view);
    nav.getNavigationBar().titleComponent.setTitle(title);
    }

    So I can push views onto my navigator like this:

    this.pushView('MyViewClassName', 'Some view title');

  9. #9
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    9
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    Awesome, glad you were able to solve it

    The framework really should offer a neat way to do this without the confusion though, I don't know what the solution looks like yet (could just be some written conventions) but it's something we're thinking about
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  10. #10
    Sencha Premium Member
    Join Date
    Feb 2012
    Posts
    86
    Vote Rating
    1
    busaware1 is on a distinguished road

      0  

    Default


    Had exactly the same problem - tearing my hair out on this one.
    I assumed I could use same xtype across platforms and that profile executed views down the tree from its initial view loaded - even using fully pathed 'requires' statements didnt help.
    profile specific xtypes fixed it - thx.
    Yes I think some guidance around this in the doco on profiles would be great.
    cheers