Results 1 to 2 of 2

Thread: Android back button click showing blank page.

  1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    5
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

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
  •