It would be great to have a method
MAElementDescription >>
attributeAt:put:
to specify new attributes for the component of a description.
Currently,
one
has to use #attributes which is not convenient.
Margritte is not a Seaside framework, generally speaking.
As far as I know there is just one use of #attributes: in SmallWiki
itself
and as I don't write code that I don't need, I didn't felt the need
for
such methods yet. However feel free to add them for your convenience,
that's the reason why there are class extensions ;-)
hm, yes, but I think this might be a feature of general interest,
because
the possibility to adapt the components when defining the description
could
be important for many forms that will be created with Magritte in the
future. Otherwise, all the form elements are bound to have the same
look
(width, height, alignment, etc.), and for forms that are a bit more
complex,
e.g., with different text areas for different types of content, it
might be
useful to adapt the look of the different form elements according to
what
they represent.
I find it very convenient just to have to specify an array, I mean
usually you have your descriptions all just at one place and one line
where you add the additional non-standard html-attributes:
(MAStringDescription selector: #foo)
attributes: { 'size' -> 12. 'maxlength' -> 14 };
....
Or how do you see the future of Magritte? I think it
has a great
potential and the possibility to customize the components easily
without subclassing might come in quite handy.
As I mentioned in the presentation, we are using Magritte in industrial
environment as well, where the users are able to click together
web-forms on their own and specify arbitrary complex validation rules.
Another issue currently is the customization of a
description if it
depends
on the instance of the structure. For instance, one would like to have
elements in a select list that are dependent on the instance of a
structure
and that cannot be determined statically. As far as I understand the
only
possibility to achieve that is to override #description on the
instance-side and to add the desired instance-dependent elements
there. Or
am I mistaken here?
Yes, you are! You can do it on the class side using the
description-builder as well. Imagine a hierarchy where A is the
superclass of B and B is the superclass of C:
A class>>descriptionFoo
^(MAOptionsDescrion key: #foo)
options: self optionsToBeUsed;
yourself.
A class>>optionsToBeUsed
^#( a b c )
B class>>optionsToBeUsed
^super optionsToBeUsed , #( 1 2 )
A will have description with #( a b c ), whereas B will have one with
#( a b c 1 2 ).
Another powerful thing is the MADynamicObject class, that allows to
define descriptions where you don't know the possible properties in
advance. Try something like:
B class>>optionsToBeUsed
^MADynamicObject on: [ 1 to: 100 atRandom ].
It is also possible to clear a description element in a subclass, by
overriding the description method and returning nil
C class>>descriptionFoo
^nil
or you could change the description of the superclass by modifying it:
C class>>descriptionFoo
^super descriptionFoo
beReadonly;
nilLabel: 'nothing';
yourself.
Och, I like objects so much ;-)
Cheers,
Lukas
--
Lukas Renggli
http://www.lukas-renggli.ch