From: Conal T. <Con...@vu...> - 2004-09-28 04:50:46
|
Kal Ahmed wrote: > I've checked in some changes for the TM4Web/Velocity package which > provides a basic level of support for listing the topic maps in a > database. You need a configuration like this: >=20 > <provider name=3D"hibernate"=20 > factory=3D"org.tm4j.topicmap.hibernate.TopicMapProviderFactoryImpl"> > <provider-properties> > <property name=3D"hibernate.connection.url"=20 > value=3D"jdbc:mysql://localhost/tm4mail"/> > <property name=3D"hibernate.connection.username" value=3D"***"/> > <property name=3D"hibernate.connection.password" value=3D"***"/> > <property name=3D"hibernate.dialect"=20 > value=3D"net.sf.hibernate.dialect.MySQLDialect"/> > <property name=3D"hibernate.connection.driver_class"=20 > value=3D"com.mysql.jdbc.Driver"/> > </provider-properties> =20 > <topicmaps template=3D"topicmap.vm"/> > </provider> >=20 > Note the extra <topicmaps/> element that is required. The template > attribute specifies the template to be used for the main=20 > topicmap page. > With this update, you are forced to always use topic.vm to render > topics, but I will work on adding support like you have in the normal > <topicmap> element to specify the template(s) to use to render topics. It's only vaguely related to Kal's post, but I thought I'd mention: I haven't used the velocity templating engine, but I have used Cocoon to = do templating. I've used Cocoon's JXTemplateGenerator, which is rather = like XSLT with JXPath instead of XPath. JXPath gives you path-based = access to Java object-graphs, e.g. x.getFoo().getBar() =3D> "x/foo/bar". = So this is similar to Velocity, and similarly I have templates = associated with various topic map objects.=20 I am keeping references to the individual JXTemplate files in the actual = topic map, where they appear as occurrences of class topics. I had = considered keeping a list of templates associated with different topics = when I realised that this is what topic maps are for :-) I don't have a = very sophisticated setup yet, but it does seem to me that referring to = templates in the map itself is potentially a powerful technique. How = does it work with the Velocity integration? Can you attach Velocity = templates to particular classes of topics, for instance? |
From: Kal A. <ka...@te...> - 2004-09-28 08:37:55
|
On Tue, 2004-09-28 at 05:47, Conal Tuohy wrote: > It's only vaguely related to Kal's post, but I thought I'd mention: > > I haven't used the velocity templating engine, but I have used Cocoon to do templating. I've used Cocoon's JXTemplateGenerator, which is rather like XSLT with JXPath instead of XPath. JXPath gives you path-based access to Java object-graphs, e.g. x.getFoo().getBar() => "x/foo/bar". So this is similar to Velocity, and similarly I have templates associated with various topic map objects. > > I am keeping references to the individual JXTemplate files in the actual topic map, where they appear as occurrences of class topics. I had considered keeping a list of templates associated with different topics when I realised that this is what topic maps are for :-) I don't have a very sophisticated setup yet, but it does seem to me that referring to templates in the map itself is potentially a powerful technique. How does it work with the Velocity integration? Can you attach Velocity templates to particular classes of topics, for instance? > > That sounds interesting - I haven't got really deeply into Cocoon so JXPath just completely passed me by :) In terms of associating templates with classes of topics for the Velocity integration, currently that is done by an external (XML) configuration file. The format allows you to specify a topic by its subject indicator and then specify a template. You can scope the application of the template to apply to: 1) Just the specified topic 2) Any instance of the topic 3) Any subclass of the topic (2) respects the subclass-superclass hierarchy, and the code attempts to locate the closest class in the hierarchy. So if you have a template person.vm scoped for instances of a topic 'Person' and then have 'Man' and 'Woman' as subclasses, person.vm would be used to render instances of 'Person', 'Man' and 'Woman'. One thing that I have found really useful in the Velocity framework is the concept of the toolbox that contains utility classes that are initialised either per-app, per-session or per-request. It makes it quite easy to integrate helpers like the TologTool. Also I find it useful to have a simple Factory helper (because there doesn't seem to be a way to initialise new objects in Velocity's templating language) - when you combine this with Mango's functional classes you can make lots of reusable helper objects that make writing the templates quite easy. Does the Cocoon framework have similar helpers ? Cheers, Kal -- Kal Ahmed <ka...@te...> techquila |