SAPUI5 Two-way binding: How do I clear/refresh the binding every time I navigate to the app? - odata

I have an issue with two-way binding when returning to a freestyle SAPUI5 app.
Say for example...
I navigate to App 1. The loads the OData fine, via two-way binding.
I then navigate away from App 1 to App 2. This also loads the OData for App 2 fine.
Now when I navigate back to App 1, The OData isn't loaded again, with the binding remaining from the first time into App 1.
I then navigate to App 2, same issue, the OData isn't reloaded, and the binding from the first entry into App 2 remains.
Ideally, I would like the binding cleared every time I enter an app, be it the 1st time in (initialization) or when navigating to it.
Is this possible to do with manifest properties? (much preferable) Or will a refresh need to be triggered in the controller?

We usually use JSON Models instead of OData Models, but whenever we run into this kind of problem, we use onBeforeRendering or onAfterRendering (depends on the situation) methods in the controller.
Thinking of sap.m.Router with routes configured in the manifest.json I don't see a configurable solution.
You could try to implement the loading via one of sap.m.routing.Router's events (e.g. routeMatched), but the last time I tried to accomplish a similar requirement like yours, I ended up in the controller again, because the routeMatched event fires before the UI elements are present when calling the view for the first time.

Related

Umbraco automatic update

I need some help with umbraco.
Let's say that I have an umbraco grid with a custom editor, just like the one in this tutorial: https://our.umbraco.com/documentation/Getting-Started/Backoffice/Property-Editors/Built-in-Property-Editors/Grid-Layout/build-your-own-editor
Ok, so I wrote this editor to build a gallery of items with image/title, I get the item list from an api call made by an angular service and this works fine when I publish the page by hand. What I want is to automatically update this gallery with new items where available, so my idea was to make a timed ajax call, let's say every hour, to update the items. But sadly this doesn't work, I suppose that the call is made but the list isn't updated.
Any suggestion? Thanks
You need to handle this differently. Right now it sounds like what you have is an implementation that works when you are browsing to this node in the backoffice using your browser and the browser makes the API calls through Angular. This all happens in your UI and when you manually hit save/publish - the data in the UI gets saved. Keep in mind that this is basically your browser doing the "work" - and this (and all other Angular code) will of course only ever run while your browser is open, in the backoffice, viewing this node.
What you want to do is to have this run automatically (and preferably in some sort of background task) to ensure that you do not really have to open up the backoffice for this to actually be automatically updated over time.
You need to create some sort of background job running on the server-side instead. This would have to be done in C# and I would recommend looking into Hangfire or Quartz frameworks to handle all the scheduling/making sure the job runs.
This job/task should do the external API calls in C# and transform the result into the same format as the format you are saving when you save data from the manual update. Then fetch the content nodes you need to update using the ContentService API and update the specific property values on those nodes. When this is done you need to make sure the changes are saved and the node is then republished with its updated data. All of this is done through the ContentService.

How to refresh all (OData) bindings of a given SAPUI5 page?

I have a bigger SAPUI5 application with multiple pages.
If user navigates through all these pages, they will reside in memory of course.
Now I have the problem that some of these pages have a complex context with several bindings to an ODataModel. That leads to the problem that a .refresh() call on the underlying ODataModel take some time.
Because: all known bindings will be reloaded (also from pages not currently shown)
Now I am searching for a better solution to refresh the ODataModel.
The refresh must be done because sometimes a client action triggers the server to updates multiple data (in different models!).
Further information (Edit)
I am using multiple ODataModels in my application and they are created in the Component.js (as suggested in the Best practice chapter of the SDK documentation).
Navigating through the pages will increase the cached data in the ODataModel.
Calling a .refresh() seems to reload all cached data (still used or not).
According to the first reply it is possible to refresh one binding but how to refresh all bindings of a given view/page with multiple models?
Would it be the right way to set multiple instances of the ODataModel for each view? And just call the .refresh() method there? But also on this scenario the locally cached data will increase over time?
Any ideas welcome :)
You can access the binding of a specific UI control and call refresh there. This should just process this specific binding.
My first hint would be to use the v2 OData Model (sap.ui.model.odata.v2.ODataModel), as it uses the Batch Mode by default.
Moreover, when it performs updates, it refreshes all bindings of entities that have been updated automatically so you should not need to refresh the whole model at all.
For me it worked to just re-bind that binding on a specific element in the view as I did earlier to create it at all.
We had an update-problem after another update call had side effects on the information in question, but a refresh on the binding of the elemnt itself did not solve that. I guess there were no local changes to that path in the model, so there was nothing to refresh. But on server-side there where updates the model/Cache didn't know about. Rebinding made my day, and also only the one necessary call to the servcie was made.

Turn on or turn off SignalR

I have a simple MVC app which displays a single table changes in the db using SignalR.
Followed the sample here with some minor changes and it works.
Currently there are only inserts so the web page shows the records.
I wanted to know if there was a way, like a switch, that can activate or de-activate the SignalR code.
Example:
There will be a checkbox which will enable or disable the showing of real time results.
Regards.

WindowsPhone not refresh/update listbox

i m writing an app where i has created an web service in local network.I m able to grab resources provided by service in android, wp7.1 and ios5.
But i faces a problem, in wp7.1 and ios5 in refreshing the list box and the uitableview controller respectively.
Actually the data source get update in both of this platform but it didn't refresh/update the view which is very important.
if any expertize knows about my problem in depth please help me out from this.if any body has sample code related to updating the view according to the web service kindly help.
i have a solution for this problem in wp7.
may be your web service call fetches the data from catch for the same service call.
try to add current time to show your web service request as new one.
like ".....?&currenttime=...."
try this.
You mention both view and controller so I'm guessing you are using some form of MVVM pattern.
For the controller to update the view a number of things must happen:
The controller must be the DataContext for the view. Most MVVM frameworks handle this plumbing for you.
The controller property that the listbox in the view is bound against must have NotifyPropertyChanged called or must be an ObservableCollection.

How to pass context around in a ASP.NET MVC web app

Ok, I'm a newbie to ASP.NET web apps... and web apps in general. I'm just doing a bit of a play app for an internal tool at work.
given this tutorial...
http://www.asp.net/learn/mvc-videos/video-395.aspx
The example basically has a global tasklist.
So if I wanted to do the same thing, but now I want to maintain tasks for projects. So I now select a project and I get the task list for that project. How do I keep the context of what project I have selected as I interact with the tasks? Do I encode it into the link somehow? or do you keep it in some kind of session data? or some other way?
As it sounds like you are having multiple projects with a number of tasks each, it would be best practise to let the project be set in the URL. This would require a route such as "/projects/{project}/tasks". It follows the RESTful URL principle (i.e. the URL describes the content).
Using session state will not work if a user possibly have different projects open in multiple browser windows. Let's say I am logging into your system and a selecting two projects opening in two tabs. First the session is set to the project of the first opened tab, but as soon the second tab has loaded, the session will be overwritten to this project. If I then do anything in the first tab, it will be recorded for the second project.
I use:
Session state for state that should last for multiple requests, e.g. when using wizards. I'd be careful not to put too much data here though as it can lead to scalability problems.
TempData for scenarios where you only want the state to be available for the next request (e.g. when you are redirecting to another action and you want that action to have access to the state, but you don't want it to hang around after that)
Hidden form fields [input type="hidden"] for state that pertains to the form data and that I want the the controller to know about, but I don't want that data displayed. Also can be used to push state to the client so as not to overburden server resources.
ok, From what I can tell, the best option seems to be to save it into the Session data
RESTful URLs, hidden fields, and session cookies are your friends.

Resources