incubator-jspwiki-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabian Sergio de Rosa" <fder...@gmail.com>
Subject Edit and update page from a plugin.
Date Tue, 24 Jun 2008 17:12:46 GMT
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);
        }
    }

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message