I'm newbie now in Model-View-Controller pattern, from perl/php it's
difficult to think in DOM-model :)
So i have two questions, answers on which i can't google:
Q1: I have a page. At page i have 2 elements. The values(data->render)
of both elements must calculated from single request to the Database.
Simple, it's looks like:
[total: 100 rows]
So, in the template i have 2 elements, with 2 data_functions:
<div n:data="totals"> - ???
<div n:data="result"> - select * from db ... where ...
But "totals" i will knew only after "result" makes request to DB
So, i must to make "select * " in data_totals(), store data in
self.var, and take it from self.var in data_result() function.
This way is not perfect to me, coz if request to DB failed - it's very
difficult to pass message about error into "request" function. May be
not difficult but not clear. :(
Another way is to use "fake" tag before "totals" and "request", like this:
Where data_real_request() doing "select *" and stores result (or error
msg) in self.var
It's not perfect too, coz we have program logic layer in template,
and, again, it's not clear to programmer.
Third way is to use 2 requests to DB - the worst way, coz requests are
long in time.
Is there another, perfect, clear way to produce such pages in nevow?
Q2: About formless. How can i use my own check of form element's value?
For example, i have "e-mail" field in form. And i wanna check char '@'
existense in it.
When my code falls into anotate.autocallable() function in
FormImplementation class - i have only values of form elements.
If e-mail value doesn't have "@"-char, how can i stop submitting and
show error near "e-mail" field in form when RenderForm() called?