diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-11-06 19:43:48 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-11-06 19:43:48 -0500 |
commit | 50e456effc2cad22d6a61e08887816096c427658 (patch) | |
tree | 36109508292ec57f01529ab31699ed8837d3f0c8 /demo/tree.ur | |
parent | 3af6c283c504e7e85d9e127f64a5eb72abe583ee (diff) |
Tree demo working (and other assorted regressions fixed)
Diffstat (limited to 'demo/tree.ur')
-rw-r--r-- | demo/tree.ur | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/demo/tree.ur b/demo/tree.ur index 06a30cf9..27e9aa21 100644 --- a/demo/tree.ur +++ b/demo/tree.ur @@ -1,3 +1,4 @@ +sequence s table t : { Id : int, Parent : option int, Nam : string } open TreeFun.Make(struct @@ -5,11 +6,28 @@ open TreeFun.Make(struct end) fun row r = <xml> - #{[r.Id]}: {[r.Nam]} + #{[r.Id]}: {[r.Nam]} <a link={del r.Id}>[Delete]</a> + + <form> + Add child: <textbox{#Nam}/> <submit action={add (Some r.Id)}/> + </form> </xml> -fun main () = +and main () = xml <- tree row None; return <xml><body> {xml} + + <form> + Add a top-level node: <textbox{#Nam}/> <submit action={add None}/> + </form> </body></xml> + +and add parent r = + id <- nextval s; + dml (INSERT INTO t (Id, Parent, Nam) VALUES ({[id]}, {[parent]}, {[r.Nam]})); + main () + +and del id = + dml (DELETE FROM t WHERE Id = {[id]}); + main () |