Thank you very much for your for your detailed example.
I'm not 100% sure this is what you're looking for
It solves the simple example I used to illustrate the problem, but
unfortunately it doesn't seem to solve the problem :(.
The problem still remains, and there are two possible paths:
1. to "decorate" a page (like SiteMesh), but keep Click features.
or
2. have several insertion points somehow.
For:
#1. I haven't found a way to do it with Click and keep it's features
(e.g. perforance filter, versioning of resources, automatic insert of
required dependencies), but I used SiteMesh with many other "dumb"
frameworks quite simply.
#2. This seems to arise from the discrepancy between the Java Page
and the template page inheritance behavior, i.e.:
- the Java Page can be extended (as often as one wishes), but
- the corresponding htm templates have no inheritance: just one level
#parse($path) trick. (most important would be the "override" behavior).
of course, this isn't the fault of Click, since Velocity templates don't
support "inheritance" (like Django).
#1 looks simpler to achieve, but I guess, it shouldn't be impossible to
achieve either, although I have only one vague idea how (but maybe the
Velocity devs have a better idea):
E.g. for
--------
class BorderPage extends Page {...}
--------
EditUserPage extends BorderPage {
void build(){
Form form ....
addButton.setInsertion(POINT_2);
}
}
--------
MoreUserPage extends EditUserPage {
void build(){
Form form ....
moreButton.setInsertion(POINT_3);
}
}
--------
the border template could look like this:
border-template.htm
----------------------
<html>
...
<div>POINT_1(DEFAULT)</div>
<div>..other stuff</div>
<div>POINT_2</div>
<div>...other stuff</div>
....
<div>POINT_N</div>
...
</html>
----------------------
edit-user.htm
-------------
$form
$addButton
------------
more-user.htm
-----------
$form
$moreButton
-----------
The "form" would be added at the "default" insertion point, so no extra
API call would be required. However, since it would be the same point,
the later one in MoreUser.java would "override" this way not only in
Java, but also in the tempalte. $moreButton on the other hand wouldn't
be override since it would use POINT_3.
Well, I guess template inheritance would be more flexible, but the
Sitemesh approach seems simpler.
regards,
Andrei.