2016-08-02 3 views
0

SAPUI5를 처음 사용했습니다. 두 개의 컨트롤러 participantList.controller.js와 Topic.controller.js가 있습니다. participantList.js에서 refreshData라는 함수를 정의했으며 Topic.Controller.js 함수를 호출하려고합니다. 전반적으로 participantList보기의 맨 위에 진행률 표시기가 설정되었습니다. 주제보기에서 주제를 선택하여 주제보기에서 참여자보기로 이동할 때마다 참여자보기에있는 진행 표시기를 다시 시작하려고합니다. 도와주세요! 여기SAPUI5에서 진행률 표시기 버튼을 다시 시작 하시겠습니까?

는 ParticipantList.controller.js에 대한 코드입니다

var reset; 
var list; 

sap.ui.define([ 
    "fiveminuteapp/controller/BaseController", 
    "fiveminuteapp/controller/Topic.controller" 
], 

function(BaseController, participant) { 
    "use strict"; 


    return BaseController.extend("fiveminuteapp.controller.participant.ParticipantList", { 

     onInit: function() { 

      var topicheader = this.byId("employeeListPage"); 
      topicheader.setTitle(topic); 

      this.listfunction(); 
      this.testFunction();    
     }, 

     refreshData: function() { 
      clearInterval(reset); 
      lTime.setText("5:00"); 
      setInterval(reset); 

     },   

     testFunction: function() { 
      var setMinutes = 5; 
      var originalTime = setMinutes * 60; 
      var time = originalTime; 
      var lTime = this.byId("labelTimeLeft"); 
      var progress = this.byId("progressIndicator"); 

      reset = setInterval(function() { 
       var minutes; 
       var seconds; 

       if (time > -1) { 
        minutes = Math.floor(time/60); 
        seconds = time % 60; 
        time = time - 1; 

        if (minutes < 10 && seconds < 10) { 
         lTime.setText("0" + minutes + ":" + "0" + seconds); 
        } else if (minutes < 10) { 
         lTime.setText("0" + minutes + ":" + seconds); 
        } else if (seconds < 10) { 
         lTime.setText(minutes + ":" + "0" + seconds); 
        } 
        progress.setPercentValue((time/originalTime) * 100); 

       } else { 
        clearInterval(reset); 
        lTime.setText("5:00"); 
        setInterval(reset); 
        if(lTime.getText() === "00:00"){ 
         $.ajax({ 
          type: "post", 
          data:{username: username}, 
          url:"/fiveminuteapp/AddPoints" 
         }) 

        } 
       } 
      }, 1000); 
     }, 

     listfunction: function(){ 
      var test = this.getView().byId("participantList"); 
      setInterval(function(){ 
       var aData = $.ajax({ 
        type: "get", 
        data:{topic : topic}, 
        contentType : "application/json", 
        url:"/fiveminuteapp/RetrieveName", 
        dataType: "json", 
        async:false, 
       }).responseJSON; 

       var oModel = new sap.ui.model.json.JSONModel(aData); 
       test.setModel(oModel, 'listmodel') 

      },5000) 
     } 
    }); 
}); 

여기 Topic.Controller.js에 대한 코드입니다

sap.ui.define([ 
    "fiveminuteapp/controller/BaseController", 
    "fiveminuteapp/controller/participant/ParticipantList.controller" 
], function(BaseController, participant) { 
    "use strict"; 

    return BaseController.extend("fiveminuteapp.controller.Topic", { 
     onNavToParticipant: function(oEvent) { 
      var otime = window.originalTime; 
      var oItem = oEvent.getSource(); 
      var oContext = oItem.getBindingContext("topics"); 
      var topicSelected = oContext.getProperty("TopicChoices"); 

      topic = topicSelected; 

      $.ajax({ 
       type: "post", 
       data:{username: username, topic : topic}, 
       url:"/fiveminuteapp/InsertTopic" 
      }) 


      this.getRouter().navTo("participantList"); 
      var time = participant.refreshData(); 
      //sap.ui.controller("ParticipantList.controller.js").refreshData(); 
     } 
    }); 
}); 

Topic view

Participant view

답변

0

I 응용 프로그램에서 Routing을 사용한다고 가정합니다. 그렇다면 라우트 패턴 매치 핸들러를 특정 라우트에 연결할 수 있습니다. 핸들러는 특정 라우트가 일치 할 때마다 프레임 워크에 의해 호출됩니다.

ParticipantList.controller.js onInit() 방법에 핸들러를 등록
oRouter.getRoute("participantList").attachPatternMatched(this._onRouteMatched, this); 

그런 다음 이름 _onRouteMatched()으로 ParticipantList.controller.js에서 핸들러 함수 자체를 구현 :

_onRouteMatched: function (oEvent) { 
    this.refreshData(); 
} 

자세한 내용은 in the official UI5 documentation를 찾을 수 있습니다.

관련 문제