Store and retrieve plugin data
Your plugin now has a sophisticated look and feel. In this last section of the tutorial you'll make your plugin fully functional. You'll add a
POST method to the admin.vm template so you can enter and retrieve user data.
This section includes the following topics:
About plugin data storage
When you added component import modules to your plugin, you added
PluginSettingsFactory. This import allows you to use
PluginSettings, a SAL service that manages your plugin data storage. The
POST method you add to your admin.vm template will submit the form to the database, and
PluginSettings permits you to retrieve stored submissions from the database.
Step 1. Add a
POST method to your admin.vm template
This is one of the most common HTTP requests. In this step, you'll add a line of code to your admin.vm file.
Open your admin.vm file from
POSTmethod in the
- Save and close the file.
Step 2. Update project files in Eclipse
In this step you'll update the dependencies in your
MyPluginServlet so you can store and retrieve data.
Replace the contents of the class with the following.
Save and close
Step 3. Enter and retrieve data
The final step is to verify that your plugin can store and retrieve data. Here you'll make an entry and confirm that you can look it up using the
PLUGIN_STORAGE_KEY. You'll perform your lookups in the Plugin Data Console.
- Reload your plugin and return to http://localhost:2990/jira/plugins/servlet/test.
- Make an entry such as Charlie/34 for Name/Age and click Save.
- Navigate to the Plugin Data Editor.
You can navigate directly to the editor at http://localhost:2990/jira/plugins/servlet/pde
Alternatively you can click Question Mark > Developer Toolbox > Plugin Data Console.
- Under Plugin Settings Query, choose Global.
- For the Data Key, enter
com.atlassian.plugins.tutorial.refapp.adminui.nameto query the names entered, or
com.atlassian.plugins.tutorial.refapp.adminui.ageto query the ages entered.
This is the
PLUGIN_STORAGE_KEYvalue that you coded into your
You'll see your entries displayed in the Results section.