Mercurial > repos > rhope
comparison said.rhope @ 147:f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 22 Nov 2010 01:15:02 -0500 |
parents | 76568becd6d6 |
children | f582fd6c75ee |
comparison
equal
deleted
inserted
replaced
146:1f39e69446f9 | 147:f3686f60985d |
---|---|
15 //First we store the value from the text box in a session variable | 15 //First we store the value from the text box in a session variable |
16 out <- [[[page]Set["said",[[page]Get Child By Name["foo"]]Value >>] | 16 out <- [[[page]Set["said",[[page]Get Child By Name["foo"]]Value >>] |
17 //Then we empty the page object | 17 //Then we empty the page object |
18 ]Clear Children | 18 ]Clear Children |
19 //And we add a hyperlink | 19 //And we add a hyperlink |
20 ]Add Child[New@Web Link["Click Here","/said"]] | 20 ]Add Child[Web Link["Click Here","/said"]] |
21 } | 21 } |
22 | 22 |
23 //This worker defines our page | 23 //This worker defines our page |
24 Said[page,query:out] | 24 Said[page,query:out] |
25 { | 25 { |
28 { | 28 { |
29 //If it's present we display it on the page | 29 //If it's present we display it on the page |
30 out <- [page]Add Child[ ["You said: "]Append[~] ] | 30 out <- [page]Add Child[ ["You said: "]Append[~] ] |
31 }{ | 31 }{ |
32 //Otherwise we provide them with a form to enter a word | 32 //Otherwise we provide them with a form to enter a word |
33 out <- [[[page]Add Child[New@Web Field["foo","","text"]] | 33 out <- [[[page]Add Child[Web Field["foo","","text"]] |
34 ]Add Child[ | 34 ]Add Child[ |
35 New@Web Button["blah","Click!"] | 35 Web Button["blah","Click!"] |
36 //The Set Handler call here attaches the worker Save Text to the click event for the page | 36 //The Set Handler call here attaches the worker Save Text to the click event for the page |
37 //Events propagate can propagate themselves up the page hierarchy and handled wherever appropriate | 37 //Events propagate can propagate themselves up the page hierarchy and handled wherever appropriate |
38 ]]Set Handler["click","Save Text"] | 38 ]]Set Handler["click","Save Text"] |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 Main[] | 42 Main[args] |
43 { | 43 { |
44 [args]Index[1] | |
45 { port <- Int32[~] } | |
46 { port <- Val[80] } | |
44 //Start Web starts the webserver and initializes the web framework | 47 //Start Web starts the webserver and initializes the web framework |
45 Start Web[ | 48 Start Web[ |
46 //It takes a dictionary mapping paths to Workers that define dynamic pages | 49 //It takes a dictionary mapping paths to Workers that define dynamic pages |
47 //Rather than just passing the name of the Worker, we're passing a List of info | 50 //Rather than just passing the name of the Worker, we're passing a List of info |
48 //that allows the framework to take care of some of the drudgework for us | 51 //that allows the framework to take care of some of the drudgework for us |
49 //The first element in the list is the worker name, the second the page title | 52 //The first element in the list is the worker name, the second the page title |
50 //and the third element indicates whether this page will be using session data or not | 53 //and the third element indicates whether this page will be using session data or not |
51 [New@Dictionary[]]Set["/said",("Said","That's what she said",Yes)] | 54 [Dictionary[]]Set["/said",[(0,"That's what she said",Yes)]Set[0,Said[?]]], port |
52 ] | 55 ] |
53 } | 56 } |