Ben Avery wrote:
in Roller 3.0rc1, I need to provide a custom calendar for our blog, which will require some Java code, and would prefer to subclass org.apache.roller.ui.rendering.model.CalendarModel rather than just hack that class, for ease of upgrades.
The only real reason to subclass that would be if you want to override the way the current calendar is rendered, otherwise I would suggest doing a custom Model since it's easier and you are less likely to cause issues.
But, searching through the code, I can't see where references to $calendarModel in weblog.vm are matched to the java class listed above.
I don't quite understand the confusion. The #showWeblogEntryCalendarXXX() macros make explicit calls to $calendarModel.XXX() methods.
I've searched all the source download, could someone please point me to where this mapping is made, or how it works, so how I could map it to e.g. ExtendedCalendarModel in the same package instead?
The way the models get added to templates is done dynamically and is controlled in the config file via the various rendering.XXXModels properties. Those properties define the set of Models which are applied to *all* renderings of the given page type. So if you were to modify the one for rendering.pageModels to use your extended Model rather than the basic CalendarModel then that's how you would insert it.
Although be very mindful that as I said, this affects *all* rendering for the given type of content. So it will affect all weblogs.
or, as I'll probably have to write more custom code to use in my theme templates, how I could use, e.g. $customModel in my roller-custom.vm macro library, to refer to a CustomModel class?
This is probably the more desirable solution. The Model interface is dead simple, so it's very easy to create your own custom Model class and structure it with any amount of code you like. Then you just need to decide if that Model is meant for only your weblog (or a limited # of weblogs) or if its meant for all weblogs.
If you want the model available for all weblogs then do as I suggested above and add it to the rendering.xxxModels config properties and it will automatically be added in. If you only want to apply it to specific models then you can do that by going the 'Settings' page for that particular weblog and entering it in down at the bottom. This way you can limit certain 'special' models to only the appropriate weblogs.
-- Allen
