You are not logged in. Click here to log in.

Support tickets can only be reported through the PTC eSupport system. More Details here.

Search In Project

Search inClear

Developing Wiki Plugins for Codebeamer: Hello World (Part 1)


Overview

Codebeamer offers a simple and flexible way to extend your wiki implementation: you can develop your own wiki plugins to integrate with external data sources and display the delivered information directly in your wiki pages.

Codebeamer's wiki engine is built on top of the JSPWiki core, so developing a wiki plugin is fundamentally identical on both platforms. It also means that most of the JSPWiki plugins can be reused and adapted to run in Codebeamer, with relatively little effort.

In this short article (the first in a series) a simple "hello world" wiki plugin for Codebeamer is described.

Step-by-step Tutorial

Setting Up Your IDE for Plugin Development

Add the following JARs to your compile-time classpath:

  • CODEBEAMER_HOME/tomcat/webapps/cb/WEB-INF/lib/cb-<version-service pack>.jar
  • CODEBEAMER_HOME/tomcat/webapps/cb/WEB-INF/lib/cb-jsp-wiki-<version-service pack>.jar

Implementing the Plugin Class

Here is the code of an example plugin that receives one optional parameter name (which defaults to "World"), and renders some welcome text based on this:

package com.intland.codebeamer.wiki.plugins;

import java.util.Map;

import com.ecyrd.jspwiki.WikiContext;
import com.intland.codebeamer.wiki.plugins.base.AbstractCodeBeamerWikiPlugin;

public class HelloWorldDemoPlugin extends AbstractCodeBeamerWikiPlugin {
	public String execute(WikiContext context, Map params) {
		String name = (String)params.get("name");
		if(name == null) {
			name = "World";
		}

		return "Hello " + name + "!";
	}
}


Implement the execute method that returns the String that will get rendered into the final HTML output. The argument context carries state information about the current wiki rendering process, while params is a named map of parameters that are passed from the markup.

For more information, please see the JSPWiki javadocs and the source code of various JSPWiki plugins .

Compiling and Deploying the Plugin

Compile this single file and copy the resulting classfile to the CODEBEAMER_HOME/tomcat/webapps/cb/WEB-INF/classes/com/intland/codebeamer/wiki/plugins directory. You can create this directory if doesn't exist yet.

(You could also repackage your classfiles to the cb-<version-service pack>.jar , but that's a more complicated approach and normally discouraged.)

Testing the Plugin

Now, restart Codebeamer to reload the wiki plugins.

Add the following markup to a wiki testpage:

[{HelloWorldDemoPlugin}]

[{HelloWorldDemoPlugin name='Joe'}]


Alternatively, you can use the generic syntax with the fully qualified classname of your plugin class if your plugin is not in the cb.wiki.plugins package:

[{INSERT com.mycompany.MyPlugin WHERE param1=value1,param2=value2 }]


What you should see now is:

Hello World!

Hello Joe!

What's Next?

We hope that after reading this article you will be able to start to extend the functionality of your wiki instance.
After this introduction, the next few articles in this series will demonstrate how to:

  • render customizable Velocity templates from wiki plugins
  • access "wiki session-scope" Codebeamer resources from wiki plugins, like the current project, current wiki page or currently signed in user
  • access external Codebeamer resources from wiki plugins, such as projects, trackers or artifacts