on 07-21-2016 12:56 PM
Hey,
I have a Fiori App where the Model is loaded via automatic model instantiation.
Is there any possibility add parameters in the init function of the Component? (or somewhere else)
I want to add header values, but I dont want to add them in the manifest.json cause of security aspect.
Thank you very much for your help.
Best regards,
David
David,
ideally you want to keep your named models listed in the manifest file, however, you can also create a named model in the component as well inside the init function and then assigning it to the view.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But when I instantiate my model via automatic model instantiation ( SAPUI5 SDK - Demo Kit ) I dont have any name of the default model?!
Or is there any other way to change values of the default model, that I can set the request headers?
Thanks
David
that is also possible.. you can have 1 unnamed model.. and many named models..
if i understand correctly, you are wanting to update properties of the model (unnamed or named)
within a controller, you can use the following line of code:
var unnamedModel = this.getView().getModel();
var namedModel = this.getView().getModel('modelName');
to read a property:
var propertyValue = model.oData.propertyName;
to update a property:
model.setProperty('/pathTo/property', propValue)
hope this is what you were looking for
Hey,
I dont wanna change the properties of a model. I wanna set the parameters of a model. Espacially the authorization header for instantiating.
I've tested it with values in the manifest.json under the default model. But is it also possible to set these values in the init Component method, before any model is instantiated?
Thanks for your help,
David
check this out.. parameters on odata models and custom headers
so would this work...
1) get a handle of your model
var model = this.getView().getModel(); // named or unnamed whichever you need
2) add custom headers
model.setHeaders( ); // pass an object with the headers you need
model.refresh(); // self explanatory
what do you need to do after here? hope this is what you need.
Don't apologize... welcome to the world of sapui5 many of us learn each day and that is a great thing
correct, you do not have a view on the component, however, you can still set it on the Component .
maybe someone else may have a different opinion ? try it and see ...
also, you may need to see what the context of the this keyword is on your component... the this keyword sometimes is out of context so make sure you have the component context for it.
good luck!
User | Count |
---|---|
76 | |
10 | |
9 | |
9 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.