MFlow  Create and maintain dynamic Web applications as easy and fast as console applications
Thou shall not write request handlers
 This release: 11/06/2014.  agocorona@gmail.com (@agocorona) <>< . issues & bugs .  Mflow Source code,     source code of this site




Multicounter widget

This example emulates the seaside example

It uses various independent copies of the counter widget instantiated in the same page. This is an example of how it is possible to compose widgets with independent behaviours

Each counter refreshes itself using autorefresh, so no page navigation happens.

Since the page flows are not persistent, when the timeout set in setTimeouts expires, the counters are reset. Here all the MFlow demo has a timeout set that is active when the multicounter demo is called.
"

Running example

(in the light red box):

This example emulates the

seaside example

It uses various copies of the

counter widget instantiated in the same page. This is an example of how it is possible to compose widgets with independent behaviours

exit



Source code:

{-# OPTIONS -XCPP #-} 
module Multicounter ( multicounter) where

import Data.Monoid 
import Data.String
import Counter(counterWidget)
-- #define ALONE -- to execute it alone, uncomment this
#ifdef ALONE
import MFlow.Wai.Blaze.Html.All
main= runNavigation "" $ transientNav multicounter
#else
import MFlow.Wai.Blaze.Html.All hiding(page)
import Menu
#endif

text= fromString
attr= fromString

multicounter= page .  pageFlow "m" $ explain
     ++> firstOf [autoRefresh $ pageFlow (show i) (counterWidget 0) <++ hr | i <- [1..4]]
     **> wlink () << p << "exit"

 where
 explain= do
       p << "This example emulates the"
       a ! href (attr "http://www.seaside.st/about/examples/multicounter")
                << " seaside example"
       p << "It uses various copies of the " <> a ! href (attr "/noscript/counter") << "counter widget "
       text "instantiated in the same page. This is an example of how it is possible to "
       text "compose widgets with independent behaviours"
 



comments powered by Disqus