Dynamic updates allow any part of the page to update itself based on change occurring on the server.
To illustrate, begin with a simple element that display the number of assets in the system.
<div>${asset_count}</div>
In Python, the asset count would be retrieved as follows.
asset_count = server.eval(“@COUNT(example/asset)”)
When the view loads, it would process the asset count on the server side and then fill in the value in HTML. The problem comes when someone else who is using the system adds another asset after a view has been loaded. The data displayed is now out of date. Normally the entire page, or in TACTIC’s case, the widget needs to be reloaded to update the correct value. However, knowing when data has changed presents a challenge.
Dynamic update solves this problem by providing a mechanism to update some part of the content based on some specified updated criteria.
For example, in the widget above, we will add an update through javascript:
<div class=”test_update”>${asset_count)</div>
In python, we would write:
kwargs[‘expr’] = “@COUNT(example/asset)”
asset_count = server.eval(kwargs.get(“expr”))
And in behaviors, we would add:
<behavior class=”test_update” event=”load”>
var expr = kwargs.expr;
spt.update.add( bvr.src_el, {
expression: expr
} );
</behavior>
This will check the expression periodically to see if the value has changed on the server. It the value changes, such as a new asset was added, this would be detected and the value of the expression will replace what is inside the “test_update” element. This is very useful for keeping values up to date on a page without having to refresh.
There is another argument called interval. Normally, a dynamic update will check every couple of seconds, however, most data this is much too often. It is possible to slow down the number of checks by setting the interval.
<behavior class=”test_update” event=”load”>
var expr = kwargs.expr;
spt.update.add( bvr.src_el, {
expression: expr,
Interval: 10,
} );
</behavior>
This will do a check on the server about every 50 seconds.
If a widget is dependent on the values of a single SObject, then we can add search_key parameter instead and this will detect if any change to a particular SObject has been made.
<behavior class=”test_update” event=”load”>
var search_key = bvr.kwargs.search_key;
spt.update.add( bvr.src_el, {
search_key: search_key,
expression: “@GET(.status),
} );
</behavior>
With the addition of a search_key, TACTIC will check if any changes have been made to that SObject. If so, it will replace the “test_update” widget with the value returned from the corresponding expression.
In order to have more control, it is possible to run some javascript.
<behavior class=”test_update” event=”load”>
var search_key = bvr.kwargs.search_key;
spt.update.add( bvr.src_el, {
search_key: search_key,
cbjs_action: “spt.panel.refresh(bvr.src_el)”
} );
</behavior>
This will update refresh the next parent refreshable widget when the corresponding SObject changes. With a javascript callback, it is possible to do a wide variety of actions.
Finally, it is possible to attach a dynamic behavior purely in Python.
div = DivWdg()
div.add_update( {
“expression”: expr
} )
This allows a widget that is entirely written using a Python class to make use of dynamic updates.
Dynamic updates provide a powerful and flexible means of update interface elements based on data changes on the server. With careful judgement about what needs to be updated and how often, data viewed on a page will never be out of date.
Nice Information Your first-class knowledge of this great job can become a suitable foundation for these people. I did some research on the subject and found that almost everyone will agree with your blog.
ReplyDeleteCyber Security Course in Bangalore
Writing in style and getting good compliments on the article is hard enough, to be honest, but you did it so calmly and with such a great feeling and got the job done. This item is owned with style and I give it a nice compliment. Better!
ReplyDeleteCyber Security Training in Bangalore
Really nice and interesting blog information shared was valuable and enjoyed reading this one. Keep posting. Thanks for sharing.
ReplyDeleteData Science Training in Hyderabad
ReplyDeleteGreat article with unique information found useful looking forward for next blog thank you.
typeerror nonetype object is not subscriptable
I finally found a great article here. I just added your blog to my bookmarking sites looking forward for next blog thank you.
ReplyDeleteData Science Course in Bangalore
I want to thank you for your efforts in writing this article. I look forward to the same best job from you in the future.
ReplyDeleteBusiness Analytics Course in Bangalore
Hello! I just want to give a big thank you for the great information you have here in this post. I will probably come back to your blog soon for more information!
ReplyDeleteData Analytics Course in Bangalore
Fantastic blog with excellent information and valuable content just added your blog to my bookmarking sites thank for sharing.
ReplyDeleteData Science Course in Chennai
I really enjoy every part and have bookmarked you to see the new things you post. Well done for this excellent article. Please keep this work of the same quality.
ReplyDeleteArtificial Intelligence course in Chennai
ReplyDeleteThank you so much for sharing this article. I really love it. This is a very nice one and gives in-depth information. I am really happy with the quality and presentation of the article. I’d really like to appreciate the efforts you get with writing this post. Thanks for sharing.
website: Matka Result
Thank a lot. You have done excellent job. I enjoyed your blog . Nice efforts
ReplyDeleteCyber Security Course in Bangalore
Nice Blog and i would like to thank for the efforts you have made in writing this post, hoping the same best work from you in the future as well. Thanks for sharing. Great websites!
ReplyDeleteTableau Training in Bangalore
Such a very useful article and very interesting to read this article, i would like to thank you for the efforts you had made for writing this awesome article. Thank you!
ReplyDeletePython Training in Bangalore