Wednesday, June 26, 2013

And finally... Widget auto refreshing

In the previous post I said:

Dinamic formlets are composable in MFlow ... But the entire page must be refreshed to achieve dynamic behavior. The next step is to try to avoid the need to refreshing the entire page by using ajax to refresh just the widget that has changed. ...

Now I did it with

autoRefresh :: View format monad result -> View format monad result

autoRefresh capture the form submissions and the links of the enclosed widget and send them via AJAX. The response is the new presentation of the widget, that is updated. No navigation occur. So a widget with autoRefresh can be used in heavyweight pages. If AJAX or javascript is not available, the widget is refreshed normally, via a new page.

This example, from :

combination = ask $
     p << "Login widget (use admin/admin)" ++> autoRefresh(pageFlow "r" wlogin)  <++ hr
     **> p << "Counter widget" ++> autoRefresh (pageFlow "c" (counterWidget 0))  <++ hr
     **> p << "Dynamic form widget" ++> autoRefresh(pageFlow "f" formWidget) <++ hr
     **> wlink () << b << "exit"

Has three active widgets (monadic formlets) with autoRefresh : A login widget, a counter and the dynamic form. They are examples  defined in the previous posts. Each of these widgets express his own flow within the page.
Post a Comment