on 01-12-2015 7:51 AM
Heya
I'm about to have a first go on UI5 and what I'm trying to do sounds rather simple to me - yet I haven't succeedet yet. Maybe someone of the comunity my be able to point me in the right direction?
My situation: I have a URL that points to my image. The URL stays the same, just the image is constantly repainted. I would like to update this new image in my view.
What I did do is the following:
I created a view and a model. The model contains the URL to the image
var dataObject = { | ||||
"src" : "http://myurl.com/current.jpg", | ||||
}; | ||||
var oModel = new sap.ui.model.json.JSONModel(); | ||||
oModel.setData(dataObject); | ||||
sap.ui.getCore().setModel(oModel); |
Then I bound this model to an image:
var myImage = new sap.m.Image("i1");
myImage.setSrc(oModel.getProperty('/src'));
Then I've added this image to a page and display this page in my app.
var page = new sap.m.Page({ | |||
title: "image", | |||
content: myImage, | |||
}); |
The result is, that the app shows the very first image but will never update the content.
How would I trigger the repeating update of this image?
HI Bernd
The image control is unable to know that the image that is referenced by the URL is changed. So you need a timer to refresh the model with a different URL to notify the image to render. You can add some random string to the URL to make the URL different from the previous one. e.g.
http://myurl.com/current.jpg?a=<uuid>;
and this will also avoid browser caching your image.
Here is an example with icon.
-D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If the URL doesn't change I think you will run into browser caching issues.
Many thanks,
Jason
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.