On 17/08/2015 13:20, Sean P. DeNigris wrote:
Anyway, the upshot is that #visible: doesn't take
a block because Magritte's
design freezes forms in time.
On 17/08/2015 13:46, Norbert Hartl wrote:
You are building a form at a specific point in time.
The view you will
see an the screen reflects that. [...] If you want to have the UI
reflect a behaviour in visibility the best way might be to recognize
the change in that boolean and to recreate/replace the view with a new
one.
Thanks. That is an important thing for me to understand. Coming from
other technologies the single thing that stands out the most about
Seaside is that components are stateful, and stick around for multiple
requests. From what you are saying Magritte goes a bit against that
notion, and that for the use case I presented "the magritte way" is to
recreate the component tree instead of keeping it around.
The relationship between uncommitted data in your form
and the change
in the structure of the view is not obvious.
I was actually not referring to uncommitted data. I am thinking of a
scenario where you are on one page, click on a button which executes a
callback in which everything validates properly, and the mementos are
committed before also effecting some changes in the domain.
But, the user stays on the same page (and thus also component) after
having clicked on this button. So, the same component is displayed again
- but some of its elements that were previously not visible now also
appear. I actually really thought this is something many people would
need to build on their user interfaces.
If you want to do things a different way, it
will take more than a block (which would still only be evaluated once), but
a rethinking of the infrastructure. Of course, this being Smalltalk, why
not!
I'd like to explore how possible this is... We already have
modifications of Magritte where we pass in a block that is evaluated
each time isVisible is called. What else would need to change? What I
know is that MAContainerComponent creates its children components upon
construction and it only creates the visible ones. I suppose one would
need to be able to refresh it somehow after a callback so that it can
update its children to include new ones that have become visible. Or
perhaps it should create all child components initially regardless of
whether they are visible or not - and only selectively render them based
on visibility. Similarly validation should probably only be propagated
to visible children.
This assumes that the child MADescriptions of the MAContainer on which
the MAContainerComponent is based do not ALSO change as a result of the
changed domain, which is not a bad assumption in my view.
Am I naive to think that it is not really much more complicated than that?
Without dedicated and specified use case it is hard to
tell if there
is a good way to do it or if there are shortcomings in magritte.
I'd happily improve the specification of my little use case if you can
point out where I am vague? I will also happily post experimental code
people can play with. We are grateful if anyone wants to participate/guide!
Regards
- Iwan
--
Reahl, the Python only web framework:
http://www.reahl.org