How to Create a Plugin Configuration Page
To create a configuration page for a plugin that does not already have the
Configure icon displayed in the
Administration page, follow these steps:
Configure icon is now displayed next to its name in the
Administration page.
Configure icon displayed in the
Administration page, follow these steps:- Register a
WebappServletextension type with aroleattribute set to config in your plugin.xml file, as in the following example:<extension type="WebappServlet" role="config" class="com.example.MyPluginConfigExtension"/>
The
classattribute value should point to an extension of the PluginConfigExtension class. - When extending the PluginConfigExtension class,
consider the following notes:
- Implement the getOptionsForm method to return an HTML form and
make sure that contains inputs with the input
nameattribute the same as the option you want to configure. - Implement the getOptionsJson method to return a JSON string of the current options for a plugin. (The JSON should only contain key values, where values is of the type string|number|boolean with no arrays or other objects).
- Implement the getPath method to return a non-empty string that
represents the path for which this extension will be served.
For example:
{webapp-context}/plugins-dispatcher/RESULT_OF_GETPATH - If you need to override the init method, make sure you call super.init(). Otherwise, options will not be saved to disk and will be lost when you restart the application.
- If you need to override any of the doPut/doDelete methods, make sure you call the saveOptions method at the end to save the options to disk.
- If you need to override the doGet method, make sure it responds
with the result of getOptionsForm for header
Accept=text/html, and with the result of getOptionsJson when called with headerAccept=application/json. Use the getOption or getDefaultOptions methods to access the current or default options.
Tip: For an implementation example, you can look at com.oxygenxml.sdksamples.github.GithubPluginConfigExtension in the webapp-github-plugin project. - Implement the getOptionsForm method to return an HTML form and
make sure that contains inputs with the input
Configure icon is now displayed next to its name in the
Administration page.