Web Content Manager(WCM)-Text Provider Plugin

Text Provider Plugin:
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.
Create Web based Project -> create class that needs to implement TextProvider or TextProviderAdapter
import java.util.Collection;
import java.util.List;
import java.util.Set;
import com.ibm.portal.ListModel;
public classTextProviderPlugin implements TextProvider{
      private static final String BUNDLE_PROPERTIES = “/com/ibm/wcmproject/nl/SimpleBundle_en.properties”;
      public static final String PROVIDER_TITLE = “Simple Text Provider”;
      public static final String PROVIDER_DESCRIPTION = “test.SimpleTextProvider”;
      public static final String RESOURCE_BUNDLE_NAME = “com.ibm.wcmproject.nl.SimpleBundle”;
      public static final String PROVIDER_NAME = “test.SimpleTextProvider”;
      protected static classSimpleLocaleListModel<K> implementsListModel<Locale>{
            /** the list of locales of this list model */
            finalList<Locale> m_localeList = new ArrayList<Locale>();
             * Constructs this simple list model holding the given locales.
             * @param p_locales
             *           the locales of this list model. May be <code>null</code>.
           * @return
            public  SimpleLocaleListModel(final Locale[] p_locales)
               if (p_locales != null)
                  for (int i = 0; i < p_locales.length; ++i)
            }           @Override
            publicIterator<Locale> iterator() throws ModelException {
                  // TODOAuto-generated method stub
                  return  m_localeList.iterator();
      private static finalListModel<Locale> ENGLISH_ONLY = newSimpleLocaleListModel<Locale>(new Locale[]{Locale.ENGLISH,Locale.FRENCH});
      //This method is used to prevent your text provider from appearing in the authoring UI
      public booleanisShownInAuthoringUI() {
            return true;
      //This method returns a description of the text provider.
      public String getDescription(Locale arg0) {
            return PROVIDER_DESCRIPTION;
      //This method returns a list of locales that are supported by this text provider.
      public ListModel<Locale> getLocales() {
            return ENGLISH_ONLY;
      //This method returns the title for the text provider that is used to allow selection of the text provider.
      public String getTitle(Locale arg0) {
            // TODOAuto-generated method stub
            return PROVIDER_TITLE;
      //This method returns a list of keys that are used when accessing the text provider.
      //These keys are displayed in the authoring UI when a user is configuring the text provider
      publicCollection<String> getProviderKeys() {
            // TODOAuto-generated method stub
            Collection<String> keys = null;
               LinkedProperties props = newLinkedProperties();
               keys = props.getKeySet();
            catch (IOException e)
               // The bundle was not found. Return null.
            return keys;      }
      //This method returns the unique name of the text provider
      public String getProviderName() {
            // TODOAuto-generated method stub
            return PROVIDER_NAME;
      //This method returns some translated text,given a key identifying the message and a locale
      public String getString(String key, Locale displayLocale) {
            String value;
               ResourceBundle bundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_NAME, displayLocale);
               value = bundle.getString(key);
            catch(MissingResourceException e)
               // The bundle or key was not found. Return null.
               value = null;
            return value;     }
         /** Used to provide the properties in order */
         private class LinkedPropertiesextends Properties {
            /** Keys */
            private finalLinkedHashSet<String> keys = newLinkedHashSet<String>();
             * @return An ordered set of keys
            publicSet<String> getKeySet()
               return keys;
            public Object put(Object key, Object value) {
                keys.add((String) key);
                return super.put(key, value);
Create properties file under com.ibm.wcmproject.nl
1.       English properties file
2.       Other language properties file
Install this plugin in using plugin.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<plugin id=“custom.plugins” name=“Custom Plugin” version=“1.0.0”
      <extension point=“com.ibm.workplace.wcm.api.TextProvider” id=“WCMTextProviderPlugin”>
            <provider class=“com.ibm.wcmproject.TextProviderPlugin” />


Leave a Reply

Your email address will not be published. Required fields are marked *

Enable Notifications OK No thanks