나는 템플릿 접근법을 추구하지 않고 새로운 SAPUI5 애플리케이션을 구축 중입니다. 제가 만들고있는 것은 두 개의 필드와 버튼이있는 작은 폼입니다. AHHhh ... "버튼".SAPUI5 : 데이터를 OData Service로 푸시하는 동안로드 대화 상자를 표시하는 방법은 무엇입니까?
버튼은 무엇입니까? 그와
<Button text="OK" width="100%" id="__button1" press="insertIntoOData"/>
나는 버튼을 누를 때 insertIntoOData 함수가 호출 될 것으로 예상 :이 버튼은 다음과 같은 코드가 있습니다. 그리고 무엇을 맞춰라!? 그것은!
환상적인! 중 하나로, OData 모델은 레코드의 삽입을 처리하는 동안 -
는 그러나 문제는 insertIntoOData에 나는 그것이 (확인이 link 조각으로 내장되어 있습니다) 대화 상자를 표시 할 것입니다. 불행히도 대화 상자를 표시하지 못했습니다. insertIntoOData 함수가 동 기적으로 호출 된 것처럼 보이며 함수가 완료 될 때까지 대화 상자가 표시되지 않습니다.
삽입 처리를 OData 모델에서 처리하면 응답이 처리되고 대화 상자는 잠시 동안 만 표시됩니다. insertIntoOData의 코드에서 알 수 있듯이 네비게이션이 마스터 (주) 페이지.
insertIntoOData: function(evt) {
/*
* to prevent namespace issues, reserve 'this' into 'that',
* so the ajax will know who to call inside its scope
*/
var that = this;
//declare the dialog
if (!that._dialog) {
that._dialog = sap.ui.xmlfragment("valac.view.requestloading", null);
that.getView().addDependent(that._dialog);
}
// open dialog
jQuery.sap.syncStyleClass("sapUiSizeCompact", that.getView(), that._dialog);
that._dialog.open();
// get the csrf token from the service url
var csrfToken = this.getCSRFToken("/valacDestination/sap/c4c/odata/v1/c4codata/ValacObjectCollection");
// get the values from the 'form'
var name_var = this.byId("tSubjectInput").getValue();
var description_var = this.byId("tDescriptionArea").getValue();
// create the entry that will be sent with the request
var oEntry = {};
// the description list
oEntry.requestDescription = [];
// the description item that goes inside the list
var entryOfRequestDescription = {};
entryOfRequestDescription.Text = description_var;
oEntry.requestDescription.push(entryOfRequestDescription);
// name is a complex object that needs to be built. Content and language.
oEntry.Name = {};
oEntry.Name.content = name_var;
oEntry.Name.languageCode = "EN";
// fetch the model schema
var oModel = new sap.ui.model.odata.ODataModel("/valacDestination/sap/c4c/odata/v1/c4codata/");
sap.ui.getCore().setModel(oModel);
/* create the entry into the model schema via ajax
* return to the master page if there's a success response
* put a message on the master page.
*/
oModel.create('/ValacObjectCollection', oEntry, null, function(response){
that._dialog.close();
sap.ui.core.UIComponent.getRouterFor(that).navTo("master");
sap.m.MessageToast.show("Object Persisted!", {
duration: 30000000
});
},function(){
that._dialog.close();
sap.m.MessageToast.show("ERROR!", {
duration: 30000000
});
});
}
내 질문은 : 가 어떻게이 insertIntoOData 종료되기 전에 대화 상자를 표시 할 수 있습니다 또는 oModel.create 함수 호출?
요청이 매우 빠르게 처리됩니다 잘 경우, 정말 대화 상자를 표시하는 의미가 않습니다 나는 다음과 같은 될 수있는 insertIntoOData 기능을 재건? 뷰 (및 컨트롤)에는 귀하의 경우에 더 적합 할 수있는 '통화 중'속성이 있습니다. – Marc
안녕하세요 @Valak, odata 요청 asyncronous 확인하십시오. 요청 생성은 기본적으로 동기식이므로 브라우저는 응답이 도착하기를 기다리고 나서 계속 진행합니다. 따라서 일단 응답이 돌아 오면 팝업이 열리지 만 다음 줄에는 팝업이 닫힙니다. 따라서 두 번째 팝업이 표시됩니다. TL : JS는 단일 스레드 언어입니다.oData.create의 async 속성을 사용하고 확인하십시오. –
@Marc : 요청이 매우 느립니다. 그래서로드하는 것이 필요합니다. 보기의 바쁜 속성은 아무 것도하지 않습니다. – Valac