[{InsertPage page=ScottHurlbertPlugins}]

Well, , so I thought I would throw something together.

When I saw this I thought it was a good idea immediately - I had recently been shown the [Visual Studio .Net|http://msdn.microsoft.com/vstudio/] [errorProvider|http://www.ftponline.com/vsm/2002_11/magazine/columns/qa/figure1.aspx] control.  This plugin is a very similar concept.

I know there is a few problems with this simple implementation:

* The icon is not replaceable
* There are probably plenty of characters that can't be placed into the comments and it currently doesn't check for any
* The comments require a parameter.  The suggested syntax is cleaner but I don't know how to do it in jspwiki.  This also means the comments must be placed within single-quotes, so there's no way to put a single quote in the comment itself.

Anyway, if you want this functionality throw this sucker in your wiki and let me know what you think.  Also, I'd be glad to hear of ways of solving some of these problems.

-- Thanks, [Scott|ScottHurlbert]

__Usage:__{{{[{INSERT com.hurlbert.jspwiki.plugin.Comment x='These are the comments'}]}}}


package com.hurlbert.jspwiki.plugin;

import com.ecyrd.jspwiki.*;
import com.ecyrd.jspwiki.plugin.*;
import java.util.*;

public class Comment implements WikiPlugin
	public String execute( WikiContext context, Map params )
		throws PluginException
		final String COMMENT_ICON 
			= "<img src=\"attach?page=Pic/smile.png\" alt=\"COMMENT\" title=\"COMMENT\"/>";
		if( !params.isEmpty() && params.values().iterator().next() != null )
			return COMMENT_ICON.replaceAll("COMMENT", 
				(String) params.values().iterator().next() );
		return "";

8/8/2004 - Made a small adjustment to add the "title" attribute.  It's turns out that alt is used by IE but HTML uses title for the tool tip text.  This code now outputs it to both.  -- [Scott|ScottHurlbert]

2005-06-22 - I see two problems.
# If no parameter is passed to the plugin you will get undefined behavior (even a NullPointerException).  It's generally not a good idea to leave too much to slump.
# In version 2.2.20 there is a hidden parameter "_body" (I think it's called) also added to the parameter-list.  There is no guarantee whatsoever that the Map will put the value from the x-parameter before the value (empty string) from the _body-parameter.
Why not iterate through all parameters to the plugin, skipping "_body" or any parameter with no value and make an icon-''each'' for the others?  [ErikAlm]


Would you please put the class file of your plugin?

--AnonymousCoward, 06-Feb-2006


Hi - could someone add a jar file for this - Thanks

--Bruce E Hayward, 02-May-2006



--AnonymousCoward, 10-May-2006


where to write in the code??

it says: "Plugin insertion failed: Could not find plugin com.hurlbert.jspwiki.plugin.Comment"

do I have to create an extern file with the code?

please explain.

--AnonymousCoward, 26-Apr-2007


Another [CommentPlugin] is part of the [CategoryAndArchiveExtensions] package. Syntax:

[{_ ... any comment text
optionally with line-breaks ...... }]

Java-Class: {{de.tuberlin.cs.flp.jspwiki.plugin._}}

--[JensGulden], 2007-05-16

Wrote a new version, since this cant handle more than one word:
--[FabianHaupt], 2008-05-28

This plugin is ''really'' badly named. It should be called IconPlugin. I was looking for a plugin to add a textbox for inserting comments and this is not what I wanted

--AnonymousCoward, 3-Feb-2011



--AnonymousCoward, 20-七月-2012 18:53