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) <>< . issues & bugs .  Mflow Source code,     source code of this site

Action example

An action is a flow attached to a widget that is executed when the widget is validated. The action receives the widget value as input. The action take control of the navigation. When the action finalizes, the flow return to the page where the widget was inserted and will return the value. If there is more than one validated widget with actions, the actions are called in sequence.

Here two widgets with two actions are called in sequence.

Running example

(in the light red box):

Two boxes with one action each one

Source code:

module Actions (actions) where

import MFlow.Wai.Blaze.Html.All hiding(page)
import Menu

actions = do
  r<- page  $   p << b <<  "Two  boxes with one action each one"
          ++> getString (Just "widget1") `waction` action
          <+> getString (Just "widget2") `waction` action
          <** submitButton "submit"
  page  $ p << ( show r ++ " returned")  ++> wlink ()  << p <<  " menu"
  action n=  page  $ getString (Just $ n ++ " action")<** submitButton "submit action"

-- to run it alone, change page by ask and uncomment this:
--main= runNavigation "" $ transientNav actions

comments powered by Disqus