SAP-Formulare ohne Frust: Mein Workflow mit dox42
Wer im SAP-Umfeld entwickelt, weiß: Formulare sind oft ein Klotz am Bein. Man verbringt Stunden mit Adobe Forms…
During the work on some Freestyle UI5 Apps I always look for a way how to save constants in Frontend. I would like to share following practice with you, which I use currently.
I am going to create a new File in my project root folder. In this file all constant and values will be stored as a JSON Object.
/webapp/model/constants.json
{
"ConstantString": "Hello World",
"ConstantInt": 123
}
I my project manifest.json, I am going to define a new JSON Model with created JSON file in URI
"models": {
"i18n": {
...
},
"constants": {
"type": "sap.ui.model.json.JSONModel",
"uri": "model/constants.json"
},
"": {
...
}
}From now on it is possible to use the constant model in View:
...
<Page id="page" title="Cadaxo UI5 Snippets #1">
<content>
<Text text="{constants>/ConstantString}" />
</content>
</Page>
...And of course also in Controllers. For example like this:
...
onInit: function () {
const oView = this.getView();
const oModel = oView.getModel("constants");
const iConstantInt = oModel.getProperty("/ConstantInt");
}
...
Let me know how you save constants in Frontend or leave a comment if you found this blog post useful!