Create a Text Provider class
A text provider is used to provide localized text that can be used within web content item forms. For example, a text provider can be used to localize the field labels or help text within an authoring template so that each user sees the labels or help text in their own language.
To use a text provider, create a text provider class and then register the text provider by deploying it on the server.
- Create a java class that implements the interface com.ibm.workplace.wcm.api.plugin.textprovider.TextProvider . This class must implement the following methods:
- public String getProviderName() {}
- This method returns the unique name of the text provider.
- public String getString(String key, Locale displayLocale) {}
- This method returns some translated text, given a key identifying the message and a locale.
- public Collection<String> getProviderKeys() {}
- This method returns a list of keys used when accessing the text provider. These keys are displayed in the authoring UI when a user is configuring the text provider.
- public boolean isShownInAuthoringUI() {}
- This method allows us to prevent the text provider from appearing in the authoring UI.
See the Javadoc documentation for further information.
- Methods inherited from com.ibm.portal.Localized must also be implemented.
- public String getTitle(Locale displayLocale) {}
- This method returns the title for the text provider that will be used to allow selection of the text provider.
- public ListModel<Locale> getLocales()
- This method returns a list of locales that are supported by this text provider.
- public String getDescription(Locale p_arg0)
- This method returns a description of the text provider.
See the Javadoc documentation for further information.
- A plugin.xml file is needed whether the deployment is done using a WAR or EAR, or using a loose jar. If deploying via an application in a WAR or EAR, include the plugin.xml file in the application's "WEB-INF" folder. When using a jar, include the plugin.xml in the root of the jar.
<?xml version="1.0" encoding="UTF-8"?> <plugin id="com.acme" name="Sample Text Provider" version="1.0.0" provider-name="IBM"> <extension point="com.ibm.workplace.wcm.api.TextProvider" id="SampleTextProvider"> <provider class="com.acme.SampleTextprovider"/> </extension> </plugin>
- Each plug-in is represented by a single <extension></extension> tag.
- The value of the point attribute must be "com.ibm.workplace.wcm.api.TextProvider".
- Provide an id value of the choice.
- Specify the provider class for the plug-in.
Naming conventions:
If we create a new plugin application with the same names and IDs as an existing plugin, the new plugin may override the first. When creating plugin applications ensure that the following are unique across the system:
- The plugin ID, plugin name and extension ID of the plugin.xml file.
- The fully qualified class name plus path of all classes within the application.
- The file path of any files within the application.
Parent: Create custom plug-ins