Add new attachment

Only authorized users are allowed to upload new attachments.

This page (revision-26) was last changed on 27-Mar-2009 15:09 by Janne Jalkanen  

This page was created on 30-May-2003 16:49 by JanneJalkanen

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Difference between version and

At line 7 added 42 lines
!How does it all work?
To utilize the JSPWiki rendering code (i.e. the TranslatorReader), you need three things:
# __A WikiEngine instance.__ It contains all of the configuration, PageProviders, etc.
# __A WikiContext.__ The WikiContext tells the TranslatorReader things like the current page name, version, stores some WikiVariables, etc.
# __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
WikiPage page = new WikiPage( "SamplePage" );
WikiContext wikiContext = new WikiContext( my_engine, page );
Alternatively, you can use the {{WikiEngine.getPage( String pagename )}} -method to get the WikiPage.
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.
At line 9 changed one line
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 );
At line 57 added 12 lines
Now you can use the TranslatorReader just as if you were using any other {{}}.
See the {{FileUtil.copyContents( Reader in, Writer out)}} if you don't want to copy it all manually.
!How can I vary the rendering?
!What other information can I get from the TranslatorReader?
Version Date Modified Size Author Changes ... Change note
26 27-Mar-2009 15:09 5.52 kB Janne Jalkanen to previous Please don't post questions in the middle, they are very confusing to others.
25 27-Mar-2009 04:00 5.763 kB to previous | to last
24 21-Jan-2009 10:42 5.52 kB to previous | to last Fixed typo in code example.
23 18-Apr-2007 09:51 5.519 kB David Au to previous | to last restored; please use the Sandbox for testing
22 18-Apr-2007 07:54 5.519 kB to previous | to last
21 18-Apr-2007 07:53 5.523 kB to previous | to last
« This page (revision-26) was last changed on 27-Mar-2009 15:09 by Janne Jalkanen