# HG changeset patch # User Adam Chlipala # Date 1241380843 14400 # Node ID c884a42599f33bd260e1126ca2b168814e7935e6 # Parent 0084af7af35a47dc543354eb1305aa6d9f160009 crud3 demo diff -r 0084af7af35a -r c884a42599f3 demo/crud3.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demo/crud3.ur Sun May 03 16:00:43 2009 -0400 @@ -0,0 +1,27 @@ +table t : {Id : int, Text : string} + PRIMARY KEY Id + +open Crud.Make(struct + val tab = t + + val title = "Crud3" + + val cols = {Text = {Nam = "Text", + Show = txt, + Widget = (fn (nm :: Name) => + + + + + ), + WidgetPopulated = (fn (nm :: Name) s => + + + + + ), + Parse = (fn p => p.A ^ p.B), + Inject = _ + } + } + end) diff -r 0084af7af35a -r c884a42599f3 demo/crud3.urp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demo/crud3.urp Sun May 03 16:00:43 2009 -0400 @@ -0,0 +1,5 @@ +database dbname=test +sql crud3.sql + +crud +crud3 diff -r 0084af7af35a -r c884a42599f3 demo/prose --- a/demo/prose Sun May 03 15:53:29 2009 -0400 +++ b/demo/prose Sun May 03 16:00:43 2009 -0400 @@ -231,6 +231,12 @@

This example shows another application of Crud.Make. We mix one standard column with one customized column. We write an underscore for the Inject field of meta-data, since the type class facility can infer that witness.

+crud3.urp + +

One thing that is unclear from the previous examples is how to provide more complex, multi-input widgets for taking input meant for particular fields. The signature of Crud.Make forces every widget to define exactly one input. The <subform> tag, the simpler cousin of the <subforms> tag that we saw earlier, provides a fix for this problem. Via <subform>, an arbitrary form can be turned into a single record-valued input.

+ +

We use that possibility here to define a silly widget for a string column, which concatenates the values entered into two different textboxes.

+ alert.urp

Ur/Web makes it easy to write code whose execution should be distributed between the web server and client web browsers. Server-side code is compiled to efficient native code, and client-side code is compiled to JavaScript. Ur/Web programmers don't need to worry about these details, because the language and standard library provide a uniform ML-like interface for the whole process.