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




A loop that concatenate text in a text box

This program uses a text box in a page within a loop that add "1" to the text input. It checks that the length of the string is less than 5. You can press the back button to see what happens.


Running example

(in the light red box):

increase a String

press the back button to go back to the menu



Source code:

{-# OPTIONS  -XCPP #-}
module IncreaseString ( clicks) where


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

clicks s= do
   s' <- page  $  p << b <<  "increase a String"
             ++> p << b <<  "press the back button to go back to the menu"
             ++>(getString (Just s)
             <* submitButton "submit")
             `validate` (\s -> return $ if length s   > 5 then Just (b << "length must be < 5") else Nothing )
   clicks $ s'++ "1"


comments powered by Disqus