2012-02-16 4 views
0

인증 양식과 탭 패널의 두 항목이있는 뷰포트가 있습니다. 이 뷰포트의 initComponent 메소드에서 사용자가 로그인과 비밀번호를 입력했는지 확인하는 함수를 호출합니다.setActiveItem 사용시 흰색 화면

그렇지 않은 경우 인증 양식이 표시되고 로그인 버튼을 클릭하면 탭 패널이 표시됩니다.

그러나 자격증 명이 저장되어있는 경우 앱이 탭 패널로 자동 전환되기를 원합니다.

app.views.Viewport = function (config) { 
    Ext.apply(this, config); 

    this.user = null; // Setter par le checkLogin ! 

    this.bottomTabs = new Ext.TabPanel({ 
     tabBar: { 
      dock: 'bottom', 
      layout: { pack: 'center' } 
     }, 
     items:[...],        
     layout: 'fit', 
     cardSwitchAnimation: false, 
    }); 

    this.userLogin = new app.views.UserLogin(); 

    //constructor 
    app.views.Viewport.superclass.constructor.call(this, { 
     fullscreen: true, 
     layout: 'card', 
     cardSwitchAnimation: 'fade', 
     items: [ 
      this.userLogin, 
      this.bottomTabs 
     ] 
    }); 

}; 

Ext.extend(app.views.Viewport, Ext.Panel, { 
    initComponent: function() { 
     app.views.Viewport.superclass.initComponent.call(this); 
     this.initialCheck(); 
    }, 

    initialCheck: function(){ 
     console.log('init'); 
     var credentials = window.localStorage.getItem("neroApp_credentials"); 
     if (credentials == null || credentials == "reset") { 
      console.log('no creds'); 
      this.setActiveItem(this.userLogin); // *** 
     } 
     else { 
      console.log('creds'); 
      Ext.Ajax.defaultHeaders = {'Authorization':"Basic " + credentials}; 
      this.checkLogin(); 
     } 
    }, 

    checkLogin: function() { 
     console.log('checkLogin'); 
     Ext.Ajax.request({ 
      url: app.stores.baseAjaxURL + '&jspPage=%2Fajax%2FgetUser.jsp', 
      scope: this, 
      success: function(response, opts) { 
       console.log('success'); 
       var user = Ext.decode(response.responseText); 
       this.user = user; 
       this.actualites.actualitesList.refreshActu(this.user, parseInt(window.localStorage.getItem("newsPerLoad"))); 
       this.setActiveItem(this.bottomTabs, { type: 'fade', duration: 500 }); 
      }, 
      failure: function(response, opts) { 
       console.log('failure'); 
      } 
     }); 
    }, 

    resetLogin: function() { 
     window.localStorage.setItem("neroApp_credentials", "reset"); 
     Ext.Ajax.defaultHeaders = {'Authorization':"Basic RESET_Credentials"}; 
    } 

}); 

하지만 때문에 * 라인의 시작에 흰색 화면을 받고 있어요 :

이 내가하고 싶었던 방법이다. checkLogin 함수의 setActiveItem이 제대로 작동하기 때문에 너무 일찍 발생했다고 생각합니다.

누구나 왜이 setActiveItem에서 오류가 발생했는지 알 수 있습니까?

감사

답변

0

좋아, 나는 문제가 나는 initComponent 함수 내에서 setActiveItem을 발사하는 것은 좋은 방법이 아닙니다 같은데요,하지만 난 마침내 설정하여 작업있어있어 비록 무엇인지 알아하지 않았다 좋아하는 항목 :

initialCheck: function(){ 
     console.log('init'); 
     var credentials = window.localStorage.getItem("neroApp_credentials"); 
     if (credentials == null || credentials == "reset") { 
      this.activeItem = this.userLogin; 
     } 
     else { 
      this.activeItem = this.bottomTabs; 
      Ext.Ajax.defaultHeaders = {'Authorization':"Basic " + credentials}; 
      this.checkLogin(); 
     } 
    }, 
관련 문제