Portlet Preferences

Home Search

How to create EDIT pages ?

To edit the preferences of a portlet you will have to create a dedicated page in your application and manipulate the PortletPreferences API to changes and store value.

Declare in "portlet.xml" that your portlet supports "Edit" mode, example

Create a preferences page for your portlet. The name of this page must be the name of the Portlet and the page must be located in a "preferences" sub package of your root package application. In our case, it will be "preferences/TapestryPortlet.java" and "preferences/TapestryPortlet.tml". You can also add the “Preferences” suffix to the page name. Now the contribution is able to run the portlet in edit mode, you have to manipulate the Preferences API and update the values with data coming from a form for example.

The code snippet above describes how you can inject PortletRequestGlobals in the page to update the portlet instance preferences and store the new values. Remind that only the portlet instance will be affected by this code.

In your Portlet, in View Mode, you will able to retrieve the value of your preferences by using the same mechanism :

More in this section