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.

Information

ExportFormatHandler is marked as unstable, so it may still change in a backward incompatible way.

MethodReturnsDefaultWhat it does
validate(Request request)booleantrue for a POST servlet request onlyWhether 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)StringnonePerforms 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.
RuleConsequence
A handler takes precedence over the export actionA handler named xar, html, pdf or after an office format replaces the native export of that format.
A replaced native format loses its rights checksThe 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 ManagerA handler installed on a wiki applies to that wiki.
A handler that fails to load is skippedA 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 GETResources 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.

Related

Get Connected