on 2017 Aug 14 2:59 PM
Hello dear Experts,
I am confused, but I can't achieve what seems to be a simple task. Here are my requirements :
I am currently designing a simple "create" application using SAPUI5 against NW Gateway oData, through SAP Cloud Network. This application should be a single page, reachable via a simple link.
My starting point is the basic "Worklist" template, which seems to be the most comprehensive template to start with... That said, it is far from beeing that intuitive... (no offense :)).
I am trying to use the "createEntry()" method which will, as far as I understand, create me an "empty" entity, or "temporary object" based upon my oData collection.
My app setting is based upon the manifest.json file.
My component.js is no more that the template-generated one :
In my init() method of my controller, i call this :
this.getRouter().getRoute("create").attachPatternMatched(this._onCreate, this);
the _onCreate() method is defined as :
_onCreate: function(oEvent) {
var oContext = this.getView().getModel().createEntry("/CustomerSet", {
success: this._fnEntityCreated.bind(this),
error: this._fnEntityCreationFailed.bind(this)
});
this.getView().setBindingContext(oContext);
},
I get this error in my console log :
I also tried instead of calling the attachPatternMatched() method :
this.getOwnerComponent().getModel().metadataLoaded().then(
this._onCreate()
);
But it seems no better :(.
Is anyone has an idea please ? Is there any comprehensive documentation on basic generated templates and why are each code lines is called ?
Thank you for your help.
Regards,
Olivier
Request clarification before answering.
From the error it is clear that before metadata is loaded you are trying to create entry. To avoid this error create the entry after checking that metadata is loaded.
_onCreate: function(oEvent) {
var oModel = this.getView().getModel();
var that = this;
oModel.attachMetadataLoaded(function(){
var oContext = oModel.createEntry("/CustomerSet", {
success: that._fnEntityCreated.bind(this),
error: that._fnEntityCreationFailed.bind(this)
});
that.getView().setBindingContext(oContext);
});
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Srikanth !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
30 | |
10 | |
8 | |
8 | |
7 | |
6 | |
6 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.