Hi!

Did you check the BugReportHandler as an example?

http://svn.apache.org/repos/asf/incubator/jspwiki/trunk/src/com/ecyrd/ jspwiki/plugin/BugReportHandler.java

/Janne

On 24 Jun 2008, at 20:12, Fabian Sergio de Rosa wrote:

I´m trying to update a page content from a plugin, but nothing is happen and
no error is showed in the logfile.
I can´t find doc about how to do that. If anyone know a example that really
works please send me.

This is my code:
    public String execute(WikiContext context, Map parameters) throws
PluginException {
...
        WikiEngine engine = context.getEngine();
        String menuTreeText = engine.getText("MenuTree");
        logger.info("MenuTree antes "+menuTreeText);
        logger.info("Matchea el texto ? " +
Pattern.compile("["+ambiente+"|"+ambiente+"]").matcher (menuTreeText).matches()); menuTreeText = menuTreeText.replace("["+ambiente +"|"+ambiente+"]", "["+ambiente+"|"+ambiente+"]\n"+"***["+nombreProyecto +"|"+nombreProyecto+"]");
        logger.info(menuTreeText);
        savePage(context, "MenuTree", menuTreeText);
...
}

//Thats the method that save a page, but nothing.
private void savePage(WikiContext context, String pageName, String text)
throws PluginException {
WikiPage newPage = new WikiPage(context.getEngine(), pageName);
        WikiContext newContext = (WikiContext) context.clone();
        newContext.setPage(newPage);
        try {
            context.getEngine().saveText(newContext, text);
        } catch (WikiException e) {
            throw new PluginException("Error al guardar ",e);
        }
    }

Reply via email to