[Haskell-cafe] YAWQ (Yet Another Wash Question)

Matthias Neubauer neubauer at informatik.uni-freiburg.de
Fri Feb 25 12:10:05 EST 2005


John Goerzen <jgoerzen at complete.org> writes:

> On Fri, Feb 25, 2005 at 04:15:55PM +0100, Matthias Neubauer wrote:
>>   standardQuery "Input Page" $ table $ do
>>     do tr $ td $ text "Hello!"
>>        h <- inputCode 
>>        tr $ td $ text "Press the button!"
>>        tr $ td $ submitCode h nextPage
>
> I like the idea, but...
>
> doesn't this still have a problem if inputCode creates multiple fields
> on the screen?  That is, h would only hold the last one?

That's what F0, F1, F2, and friends are for. You use them to wrap
multiple handles into a single object that you then pass to a submit
button.

E.g., my example, now with two buttons on the first step, looks as
follows ...

controller :: CGI ()
controller = 
  let input1  = do h1 <- tr $ td $ textInputField empty
                   h2 <- tr $ td $ textInputField empty
                   return (F2 h1 h2)
      submit1 = \ h cont -> submit h cont empty
      page1   = stepOneTemplate input1 submit1 page2

      vali2   = \ (F2 h1 h2) -> value h1 ++ " and " ++ value h2
      out2    = \ t -> text t
      submit2 = \ cont -> submit0 cont empty
      page2   = stepTwoTemplate vali2 out2 submit2 page3
     
      ...

The templates and all the rest stays unchanged.

-Matthias
 




-- 
Matthias Neubauer                                       |
Universität Freiburg, Institut für Informatik           | tel +49 761 203 8060
Georges-Köhler-Allee 79, 79110 Freiburg i. Br., Germany | fax +49 761 203 8052


More information about the Haskell-Cafe mailing list