1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    5
    Vote Rating
    0
    tarakkar is on a distinguished road

      0  

    Default Unanswered: Android back button click showing blank page.

    Unanswered: Android back button click showing blank page.


    I am new to sencha. Almost spent 2 day to understand sencha routing/history support to implement android back button. but ended up with blank screen always although navigation is working. Please help me to find out what wrong am i doing or what is wrong with my application architecture.

    app.js
    Code:
    Ext.application({
        name: "WorkFlow",
       
        models: [],
        stores: [],
        controllers: ["WFController"],
        views: ["LoginForm","WorkList"],
    
        launch: function () {
    
             var loginForm = {
                 xtype: "loginform"
             }; 
             
             var workList = {
                     xtype: "worklist"
             };
            
            Ext.Viewport.add([loginForm,workList]);
            
        // set up a listener to handle the back button for Android 
            if (Ext.os.is('Android')) {
                
              document.addEventListener("backbutton", Ext.bind(onBackKeyDown, this), false);  
    
              function onBackKeyDown(e) {
                  
                  e.preventDefault();
                 
                  // you are at the home screen
                  if (Ext.Viewport.getActiveItem().xtype == loginForm.xtype ) {
                   
                  navigator.app.exitApp();
                  }else {
                    
                          this.getApplication().getHistory().add(Ext.create('Ext.app.Action', {
                          url: 'loginForm'
                      }));
                  }
              }
           }
            
        }
    });
    LoginForm.js
    Code:
    var formPanel = null;
    
    Ext.define("WorkFlow.view.LoginForm", {
        extend: "Ext.form.Panel",
        alias: "widget.loginform",
       
        initialize: function () {
    
         this.callParent(arguments);
    
         formPanel = Ext.create('Ext.form.Panel', {
                fullscreen: true,
    
                  items: [{
                            xtype: 'titlebar',
                            title: 'Login',
                            docked: 'top'
                        },
                        {
                        xtype: 'fieldset',
                        items: [
                        {
                            xtype: 'textfield',
                            name : 'username',
                            label: 'Username',
                        },
                        {
                            xtype: 'passwordfield',
                            name : 'password',
                            label: 'Password',
                        },
                        {
                            xtype: 'textfield',
                            name : 'deviceId',
                            label: 'Device Id',
                        }
                    ]
                }]
            });
    
           formPanel.add({
                xtype: 'toolbar',
                docked: 'bottom',
                layout: { pack: 'center' },
                items: [
                    {
                        xtype: 'button',
                        text: 'Login',
                        handler: this.onLoginTap,
                        scope: this
                    },
                    {
                        xtype: 'button',
                        text: 'Cancel',
                        handler: function() {
                            formPanel.reset();
                        }
                    }
                ]
            });
    
        },
        
        onLoginTap: function() {
            this.fireEvent("loginCommand", this);
        },
    
    });
    WorkList.js
    Code:
    Ext.define("WorkFlow.view.WorkList", {
        extend: "Ext.form.Panel",
        alias: "widget.worklist",
       config:{
       html: 'This is worklist...',
       
       } 
    });
    WFController.js
    Code:
    Ext.define("WorkFlow.controller.WFController", {
        extend: "Ext.app.Controller",
    
         config: {
              refs: {
                   
                loginForm: "loginform",
                workList: "worklist",
            },
            control: {
                loginForm: {
                    loginCommand: "onLoginCommand",
                }
            },
            routes: {
                'loginForm': 'activateLoginFormPage'
            }
        },
        activateLoginFormPage: function(){
                Ext.Viewport.animateActiveItem(this.getLoginForm(), this.slideRightTransition);    
        },
    
         slideLeftTransition: { type: 'slide', direction: 'left' },
        slideRightTransition: { type: 'slide', direction: 'right' },
       
       onLoginCommand: function () {
    
          var values = formPanel.getValues();
         window.plugins.AuthPlugin.authenticate(values.username,values.passwordvalues.deviceId,values,
          function loginCallBack(result){
    
               if(result=="PASSWORD_MATCH"){
                            
                loginForm.onLoginSuccess();
               }
            });
        },
    
         onLoginSuccess: function(){
        
        this.getApplication().getHistory().add(Ext.create('Ext.app.Action', {
        url: 'loginFormroute/workList'
        }));
     
           Ext.Viewport.animateActiveItem(this.getWorkList(), this.slideRightTransition);     
        },
        
        launch: function () {
        },
        init: function () {
        }
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Answers
    3541
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    When you go back, is it trying to go to the URL that has no hash in it? Like when you first start your app there is no hash so if you go forward there is one and go back it will have no hash.

    Do you understand what the fullscreen config actually does?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread