Wiki source code of Export Format Handler API

Last modified by Vincent Massol on 2026/11/30 16:49

Show last authors
1 {{version since="18.4.7, 18.9.0RC1"}}
2 ##org.xwiki.export.ExportFormatHandler##, in ##xwiki-platform-oldcore##, is the Component role the [[export action>>doc:documentation.xs.dev.exports.WebHome]] looks up, using the ##format## request parameter as hint, or ##xar## when the request has none.
3 {{/version}}
4
5 {{info}}
6 ##ExportFormatHandler## is marked as unstable, so it may still change in a backward incompatible way.
7 {{/info}}
8
9 |=Method|=Returns|=Default|=What it does
10 |##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.
11 |##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.
12
13 |=Rule|=Consequence
14 |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.
15 |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.
16 |The lookup uses the context Component Manager|A handler installed on a wiki applies to that wiki.
17 |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.
18 |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.
19
20 A format that only renders a Page, like a view request, overrides ##validate##:
21
22 {{code language="java"}}
23 @Override
24 public boolean validate(Request request)
25 {
26 // This format only renders the Page, like a view request.
27 return true;
28 }
29 {{/code}}

Get Connected