Hi All,
I have been trying to figure out this issue for a few days now and done a lot of searching. I have a custom property created on the View which pulls in a dataset from a Named Query. On the initial load of that page/view in a web browser the data is pulled in correctly with the right datetime stamp from the database showing when the query executed. However, when I try to reload the page in the browser, the data does not get reloaded and the datetime stamp is not updated from the database. The named query’s cache is unchecked so it shouldn’t be caching the data.
Is there something I am missing on this?
Thanks in advance.
Hi @dennis.powell, I am not familiar with how it works, but I have experienced similar events. Not sure if it’s how the session persists… but there are way better people on here to explain it.
In short, I can’t answer your initial question, but I may be able to assist on what you are aiming to do (maybe ). I assume you require a refresh of the data based on an action, is this correct?
If so you can use the refreshBinding()
script function. For example, edit the following code in the onActionPerformed event of a button to fit your circumstance: self.view.refreshBinding("custom.property")
Hi @matthew.ayre, I tried that on the view itself in the OnStartUp event with no luck. All I’m trying to to is have get fresh data from the database when a user clicks on the browser’s “reload/refresh” button. Right now it is not refreshing and acting like the data is cached.
Here is a screenshot of the page and what I’m doing. So the inital load will pull in the data and then I click on the web browser’s reload button (red arrow is pointing at it) and the page reloads, yet all the data is exactly the same as the initial page load. I also highlighted all the data that should be updated.
What is expected is that when the page reloads, the data is updated and the Date Range time to be updated. It currently is not.
This is basically by design.
To Perspective, there’s no difference between a user reloading the page and the connection briefly dropping (e.g. due to spotty wifi). Since we don’t want to always reload the page in the latter case, we don’t always reload the page in the former case.
I think the Page Startup script event will capture a reload, so you could potentially add your own handling to this scenario that way.
1 Like
Thanks for the reply @PGriffith. That makes sense.
I have set up a button on the page for testing purposes and I can get a table that is bound to the Named Query to rebind/reload the data. However, I can’t seem to get a custom property set on the view that is bound to the Named Query to rebind/reload.
I’ve tried the following script on the button OnActionPerformed.
vwProp = self.view.custom.CycleTimeData
vwProp.refeshBinding(self.view.custom.CycleTimeData)
I even tried setting the refeshBinding to the view and neither worked. Am I setting up the script wrong or can the refreshBinding work on a Custom Property?
self.view.refreshBinding("custom.CycleTimeData")
1 Like
@cmallonee, Thank you! That worked on the button script. I tried it on the view onStartup event and it didn’t work. I even tried the below script with no luck.
self.refreshBinding(“custom.CycleTimeData”)
I even tried a refreshBinding on the table OnStartup and it won’t refresh on a page reload from the browser.
As Paul said, page reload is deliberately not restarting your session/page/view. So of course the onStartup events aren’t running again. You will need something else (like the button) to make things refresh.
1 Like
@pturmel, Ok, I’ll go that route then. Thank you all for the help.
Here’s the problem you’re running into:
As far as Perspective is concerned, a browser refresh does NOT restart the page or the view, because a browser refresh is basically considered a short disconnect from the point-of-view of the Gateway. So in the past, users had no way to trigger a script if a user refreshed a page. To help, we bundled browser refresh events into triggers for the PAGE onStartup event so that users could reliably execute code during a browser refresh. We did nothing of the sort for Views. Your View is not technically directly connected to the Page, so you have no direct access (ie: from the page onStartup Event, you may not do something like self.view
).
I think that we could make use of some trickery here. As of 8.1.12, Pages have a urlParams
object which the View has access to.
In Page onStartup:
page.props.urlParams.refresh = True
Add a new custom property to the VIEW, and name it refresh
.
Bind this new property to this.page.props.urlParams.refresh
, and make sure that you set the “Overlay opt-out” checkbox to be checked.
This binding will also need a script transform:
if value:
# only do this if the property is found and needs to be done
self.refreshBinding("custom.CycleTimeData")
self.page.props.urlParams.refresh = False
return value
4 Likes
Where do you get the 'self.page.props.urlParams.refresh'? I don't see it in the page props, nor in the docs Pages in Perspective | Ignition User Manual
What I'm looking for is writing back to the urlParams, and seeing the url change in the browser without whole Ignition reloading.
It's an url parameter, so it's up to you to add it.
Putting page.props.urlParams.refresh = True
will create it.
I don't think you can do that.
Ah, that was not my brightest moment, thanks.
But It's still not possible to write to the urlParams and seeing the change in the browser without a refresh, right?
Even with a refresh, I don't think what you write into page.props.urlParams
will reflect back to the browser. Actually it might even be overwritten on refresh.
What I mean is doing this
system.perspective.navigate("/new-page?test=5")
It does give you '/new-page?test=5' in the browser, but it does not show up in the urlParams, unless you refresh. Thats unlucky if you want to rely all logic on that.
I'm pretty sure you need to use url navigation to pass url parameters.
Yup, which triggers a refresh, which is unfortunate.