This is version . It is not the current version, and thus it cannot be edited.
[Back to current version]   [Restore this version]

This page still under construction

Current known JSPWiki embedders:

How does it all work?#

To utilize the JSPWiki rendering code (i.e. the TranslatorReader), you need three things:

  1. A WikiEngine instance. It contains all of the configuration, PageProviders, etc.
  2. A WikiContext. The WikiContext tells the TranslatorReader things like the current page name, version, stores some WikiVariables, etc.
  3. A TranslatorReader. This is the heavy lifter that does all of the translating.

How to get a WikiEngine?#

public WikiEngine getEngine( HttpServletRequest request )
{
    ServletConfig config = request.getSession().getServletContext().getServletConfig();
    WikiEngine my_engine = WikiEngine.getInstance( config );
    return my_engine;
}

You can instantiate a WikiEngine through

    Properties properties = new Propeties();
    // set properties
    WikiEngine my_engine = new WikiEngine( properties );

but this is not recommended, since WikiEngines should really be singletons across your application (or context - if you have different applications running in the same JVM).

After you have created a WikiEngine, you can then reuse this object all over again. Note that there is a significant penalty in creating a WikiEngine, so you definitely want to cache this object.

How do I get a WikiContext#

Simple. If you have a HttpServletRequest handy, you can just go

    WikiContext wikiContext = myWikiEngine.createContext( request, WikiContext.VIEW );

Another option is to create one for yourself with:

    WikiPage page = myWikiEngine.getPage( "SamplePage" );
    WikiContext wikiContext = new WikiContext( my_engine, page );
    wikiContext.setRequestContext( WikiContext.VIEW );

Alternatively, you can use the WikiPage constructor -method to get the WikiPage. This is not recommended, however, because using getPage() gives you the benefits of the built-in caches.

The WikiContext holds the current rendering context. The WikiContext is created at the beginning of the request, and discarded after the response has been sent back to the client program. It is probably not a good idea to reuse this object.

How to use the TranslatorReader?#

After you have the WikiContext, you can simply create a new TranslatorReader by using

    TranslatorReader my_reader = new TranslatorReader( wikiContext,
                                                       new StringReader( my_page_data );

Now you can use the TranslatorReader just as if you were using any other java.io.Reader.

See the FileUtil.copyContents( Reader in, Writer out) if you don't want to copy it all manually.

How can I vary the rendering?#

TBA.

What other information can I get from the TranslatorReader?#

TBA.

What libraries (Jars) do I need?#

TBA

How do I make JSPWiki's logging play nice with my app's Log4j setup?#

TBA

BTW, I am not very adept at log4j config, so if someone else can help me out here, it would be cool. --JanneJalkanen.

Add new attachment

Only authorized users are allowed to upload new attachments.
« This particular version was published on 22-May-2005 18:02 by Administrator.