incubator-jspwiki-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Janne Jalkanen <Janne.Jalka...@ecyrd.com>
Subject Re: Edit and update page from a plugin.
Date Sat, 28 Jun 2008 17:53:29 GMT


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);
>         }
>     }


Mime
View raw message