Export Format Handler API
Last modified by Simon Urli on 2026/10/15 11:37
Reference
XWiki 18.4.7+, 18.9.0+ org.xwiki.export.ExportFormatHandler, in xwiki-platform-oldcore, is the Component role the export action looks up, using the format request parameter as hint, or xar when the request has none.
| Method | Returns | Default | What it does |
|---|---|---|---|
| validate(Request request) | boolean | true for a POST servlet request only | Whether the request is meant to perform the export. When it returns false, the export action answers with the 405 (Method Not Allowed) status code and the "Confirm the Export" page. |
| export(XWikiContext context) | String | none | Performs the export, with the requested Page revision already set on the context. Returns the name of the template to render, or null when it wrote the response itself. |
| Rule | Consequence |
|---|---|
| A handler takes precedence over the export action | A handler named xar, html, pdf or after an office format replaces the native export of that format. |
| A replaced native format loses its rights checks | The native xar export requires administration rights on the wiki and the native html export keeps only the viewable Pages: a handler replacing them checks the rights on the exported Pages itself. |
| The lookup uses the context Component Manager | A handler installed on a wiki applies to that wiki. |
| A handler that fails to load is skipped | A warning is logged and the request falls back to the native format of the same name, if any. |
| Only a format that just renders a Page should accept GET | Resources loaded with relative URLs from a Page served by the export action usually carry no format parameter, so a xar handler must not accept GET requests. |
A format that only renders a Page, like a view request, overrides validate:
@Override
public boolean validate(Request request)
{
// This format only renders the Page, like a view request.
return true;
}FAQ
Which Request class does validate() take?
org.xwiki.container.Request, from xwiki-platform-container-api; the default implementation reads the HTTP method from its ServletRequest implementation, in xwiki-platform-container-servlet.