[Ur] More questions: sql_injectable, reactivity and interaction with CSS
Artyom Shalkhakov
artyom.shalkhakov at gmail.com
Tue Jan 12 00:08:41 EST 2010
2010/1/11, Adam Chlipala <adamc at impredicative.com>:
> Artyom Shalkhakov wrote:
>> First, Is there any way to write an sql_injectable instance?
>
> Yes, but only by building on the instances included in [Basis].
>
>> I'd like
>> to serialize and deserialize a tree data structure (xbody in
>> particular) to store it in the database.
>>
>
> The Ur/Web version in the public Mercurial repo includes a new type
> family [Basis.serialized], such that any [serialized t] is
> [sql_injectable]. See basis.urs for the details. I should make a new
> release in the next few days, and it will contain this functionality
> (and you can use the repo's version for now, if you can't wait).
Okay, I'll wait. Thanks.
>> I'm trying to write a simple in-place editor for text. Given some text
>> on a webpage, users can double-click on a paragraph, say, which turns
>> the text into a text box and two buttons (apply and cancel). I don't
>> know how to do this.
>
> Well, you could, say, create a [source bool] that is changed by the
> [onclick] handler of the paragraph. The paragraph content would be a
> <dyn> that does different things based on the source's value.
Here's what I do:
> fun editable () =
> m <- source False; (* mode: editing or viewing *)
> t <- source "click to edit";
> let
> fun act () =
> m' <- signal m;
> return (if m' then
> <xml><ctextbox source={t}/><button onclick={set m False}/></xml>
> else <xml><dyn signal={t' <- signal t; return (cdata t')}/></xml>
> in
> return <xml><body>
> <div onclick={m' <- get m; if not m' then set m True else return ()}>
> <dyn signal={act ()}/>
> </div>
> </body></xml>
> end
I think it should work but actually clicking on the button doesn't
revert the mode from editing to viewing. Is there something I do
wrong?
Cheers,
Artyom Shalkhakov.
More information about the Ur
mailing list