Most programming language tutorials start with a "Hello, World!" example which simply displays a fixed text in a console window (or similar).kkkk
The "sayHello" plugin follows the same spirit and inserts its message into the running HTML code at the position where it has been invoked.
Compilation
Save the source code shown at the bottom of this page into a file called sayHello.java. Then invoke the Java compiler as follows
javac sayHello.java(or similar - depending on the development environment you are using)
Installation
Create a JAR archive containing the Java class file for the plugin. You may use the command
jar cvf sayHello.jar sayHello.classfor that purpose.
Then move that file into any directory within your wiki's class path - preferrably into the WEB-INF/lib/ folder within your web server's web application directory for the JSPWiki.
Finally restart the Wiki for the plugin to be recognized.
Usage
Within wiki markup, invoke the plugin as follows
[{sayHello}]
The plugin does not accept any parameters. Additionally, as the class resides in the default directory, there is no need neither to prefix the plugin name with a package path nor to modify the plugin search path within the JSPWiki configuration file.
When viewing the wiki page, the plugin invocation will be replaced by the fixed text
"Hello, World!" (issued by the "sayHello" plugin)
Source Code
import java.util.*; // Java utility classes and data structures
import com.ecyrd.jspwiki.*;
import com.ecyrd.jspwiki.plugin.*;
public class sayHello implements WikiPlugin {
public String execute (WikiContext Context, Map ParameterMap) {
return "<i>\"Hello, World!\"</i> (issued by the \"sayHello\" plugin)";
}
}
Andreas Rozek
(EMail: Andreas.Rozek@GMX.De
)