#: Boris Kraft changed the world a bit at a time by saying on 10/22/2005 10:42
PM :#
On 22.10.2005, at 13:19, Alexandru Popescu wrote:
Hi!
Last nite I was trying to obtain/to make a
info.magnolia.cms.gui.control.Tree control not to display a <select/>
tag for some columns.
After some investigation, the only solution that I have figured out
was to extend the control and override the getHtmlHeader(),
getHtmlFooter(), getHtmlChildren() and getHtmlChildrenOfOneType(), but
copy some of the code in there.
I couldn't do this, as it may open the door to so many problem.
Instead I come up with a `crazy´ idea: what if the control renders his
content through some templates and it is just passing to that
templates the parameters it needs.
I have jumped to try this idea with FreeMarker (the reasons for
choosing FreeMarker over Velocity are not subject to this mail ;-) ).
Indeed there are a couple of simple things to be done to enable this
(I can say under 50 lines of code). But the final solution is looking
great - at least in my opinion:
the extended Tree control is reduced with over 450lines (all those
meant to create HTML output) and these were replaced with 3 FreeMarker
templates that are not longer than 50-80 lines. Even more important,
doing this will allow me to make my control render in whatever format
I want it to. Plus, I can still have the other controls render their
content inside the template (as FreeMarker allows me to call methods
on objects). And last, but not least it became readable (again my
opinion).
Having a template (view) and a model separated is a very good thing of
course. But I'd use JSP not FreeMarker in the context of Magnolia.
Sure, JSP will work here too. But from a point of view of performance, there is not comparison
possible. FreeMarker, Velocity are better template engines (they are doing smart caching, expression
navigation, etc).
As I already said about this matter: I would prefere to have the controls view rendered by an easy
solution; not everybody will use the set of provided controls (... and I have a good example for
this: myself :-) ). So, the easier it is to create/customize controls the sooner we will see more
interesting controls out there.
> Your
> code examples don't seem better readable to me in FreeMarker than they
> were in Java, though.
Wow... seems like you read it for quite a few times, cause I haven't been able to feel confortable
with it in a normal amount of time ;-).
And of course the idea is still out there to use JSF for the controls
(not for templating) in M3.
Philipp has done a lot of thinking about the tree control, I am sure he
will add a few comments. But its clear we need to make it a lot more
flexible.
Cheers
Boris
----------------------------------------------------------------
Yep I know. But it is not just a matter of controls here. And also this separation of controls (seen
as internal stuff) vs templating (seen as public stuff) is not so correct. Currently I cannot create
my templates as I am unable to present my repository. I agree that maybe not all the users will
really need this, but as it is said: 'make the simple things easy and complex things possible'.
cheers,
./alex
--
.w( the_mindstorm )p.
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------
----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------