[Ur] Forms that call rpc instead of redirect
Artyom Shalkhakov
artyom.shalkhakov at gmail.com
Mon Feb 12 00:31:04 EST 2018
Hello Aistis,
2018-02-12 4:03 GMT+06:00 Aistis Raulinaitis <sheganinans at gmail.com>:
> Yes I did get a little demo working with ctextbox, cchecbox, and the like.
> However the result is much more verbose and more likely to have runtime
> errors over a regular form.
>
> The way that a form will pack all of its contents into a stuct is a clear
> advantage over the source based route. It requires defining possibly many
> sources and wiring them all into the right slots, having to call "get" on
> each one of them in the onclick handler and then wire all the gotten values
> into the handler.
>
>
FWIW, you can define something like this:
https://github.com/ashalkhakov/urweb-projects/blob/master/meter/screens.ur#L163
and then use it like this:
https://github.com/ashalkhakov/urweb-projects/blob/master/meter/screens.ur#L192
And it's not too bad.
> Losing the form submit struct typing mechanism and the added verbosity of
> all the sources would be very painful if you are expecting the majority
> of your forms to be of this style. Which I am.
>
> On Feb 11, 2018 13:20, "Adam Chlipala" <adamc at csail.mit.edu> wrote:
>
>> I think that kind of form has gone out of style, and I personally almost
>> always use the Ur/Web tags like <ctextbox> to collect data and then choose
>> RPCs programmatically.
>>
>> On 02/11/2018 04:10 PM, Aistis Raulinaitis wrote:
>>
>>> The form mechanism is excellent, with the built in type checking, but
>>> the submit action function returns a page: state -> transaction page.
>>>
>>> Is there such a thing such as a version of forms that has a submit
>>> action function with a type of: state -> transaction unit.
>>>
>>> This is so I can call rpc functions there in the submit action and then
>>> the current page is updated using responses over a channel from the server.
>>>
>>
>>
>> _______________________________________________
>> Ur mailing list
>> Ur at impredicative.com
>> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
>>
>
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
>
>
--
Cheers,
Artyom Shalkhakov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20180212/c0b6c342/attachment.html>
More information about the Ur
mailing list