Friday, 30 September 2016

Dynamic updates when data changes.

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.

31 comments:

  1. 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.
    Cyber Security Course in Bangalore

    ReplyDelete
  2. 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!
    Cyber Security Training in Bangalore

    ReplyDelete
  3. Really nice and interesting blog information shared was valuable and enjoyed reading this one. Keep posting. Thanks for sharing.
    Data Science Training in Hyderabad

    ReplyDelete

  4. Great article with unique information found useful looking forward for next blog thank you.
    typeerror nonetype object is not subscriptable

    ReplyDelete
  5. I finally found a great article here. I just added your blog to my bookmarking sites looking forward for next blog thank you.
    Data Science Course in Bangalore

    ReplyDelete
  6. 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.

    Business Analytics Course in Bangalore

    ReplyDelete
  7. 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!

    Data Analytics Course in Bangalore

    ReplyDelete
  8. Fantastic blog with excellent information and valuable content just added your blog to my bookmarking sites thank for sharing.
    Data Science Course in Chennai

    ReplyDelete
  9. 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.
    Artificial Intelligence course in Chennai

    ReplyDelete

  10. Thank 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

    ReplyDelete
  11. Thank a lot. You have done excellent job. I enjoyed your blog . Nice efforts
    Cyber Security Course in Bangalore

    ReplyDelete
  12. 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!
    Tableau Training in Bangalore

    ReplyDelete
  13. 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!
    Python Training in Bangalore

    ReplyDelete
  14. I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.
    Data Science Course in Chennai

    ReplyDelete
  15. All of these posts were incredible perfect. It would be great if you’ll post more updates and your website is really cool and this is a great inspiring article.
    Artificial Intelligence course in Chennai

    ReplyDelete
  16. I just would like to give a huge thumbs up for the great info you have here on this post. Thanks for sharing with us. Are you looking for Escort Services in Ahmedabad and Call Girls in Ahmedabad
    Click For More Information Escorts Agency Ahmedabad

    ReplyDelete
  17. Awesome article. I enjoyed reading your articles. this can be really a good scan for me. wanting forward to reading new articles. maintain the nice work!
    Data Science Courses in Bangalore

    ReplyDelete
  18. I am sure it will help many people. Keep up the good work. It's very compelling and I enjoyed browsing the entire blog.
    Business Analytics Course in Bangalore

    ReplyDelete
  19. Excellent Blog! I would like to thank you for the efforts you have made in writing this post. Gained lots of knowledge.
    Data Analytics Course

    ReplyDelete
  20. What an incredible message this is. Truly one of the best posts I have ever seen in my life. Wow, keep it up.
    AI Courses in Bangalore

    ReplyDelete
  21. You have completed certain reliable points there. I did some research on the subject and found that almost everyone will agree with your blog.

    Data Science Training in Bangalore

    ReplyDelete
  22. Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such amazing content for all the curious readers who are very keen on being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in the future too.

    Digital Marketing Training in Bangalore

    ReplyDelete
  23. I found Habit to be a transparent site, a social hub that is a conglomerate of buyers and sellers willing to offer digital advice online at a decent cost.

    Artificial Intelligence Training in Bangalore

    ReplyDelete
  24. Truly incredible blog found to be very impressive due to which the learners who go through it will try to explore themselves with the content to develop the skills to an extreme level. Eventually, thanking the blogger to come up with such phenomenal content. Hope you arrive with similar content in the future as well.

    Machine Learning Course in Bangalore

    ReplyDelete
  25. Nice Post | I have read your blog. Each and every concept explaining very clearly. Thanks for sharing your valuable information...

    Data Science Training in Hyderabad

    ReplyDelete
  26. I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!

    AWS Training in Hyderabad

    ReplyDelete
  27. You have completed certain reliable points there. I did some research on the subject and found that almost everyone will agree with your blog.

    Data Science Training in Bangalore

    ReplyDelete
  28. Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such amazing content for all the curious readers who are very keen on being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in the future too.

    Digital Marketing Training in Bangalore

    ReplyDelete
  29. I wanted to leave a little comment to support you and wish you the best of luck. We wish you the best of luck in all of your blogging endeavors.

    Artificial Intelligence Training in Bangalore

    ReplyDelete
  30. The Extraordinary blog went amazed by the content that they have developed in a very descriptive manner. This type of content surely ensures the participants explore themselves. Hope you deliver the same near the future as well. Gratitude to the blogger for the efforts.

    Machine Learning Course in Bangalore

    ReplyDelete
  31. Thanks for Sharing this Valuable Information with us: this is very useful for me. Keep it Up. Trending Blogs India 2021, Most Popular Blog Topics India 2021, Trending Topics in India 2021
    Visit here - breaking news india pakistan

    ReplyDelete