JBoss.orgCommunity Documentation

Register your UI Action

To register your UI Action, do as follows:

1. Create the code:




<configuration xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">

    <external-component-plugins>
        <target-component>org.exoplatform.webui.ext.UIExtensionManager</target-component>
        <component-plugin>
            <name>Add.Actions</name>
            <set-method>registerUIExtensionPlugin</set-method>
            <type>org.exoplatform.webui.ext.UIExtensionPlugin</type>
            <init-params>
                <object-param>
                    <name>CacheView</name>
                    <object type="org.exoplatform.webui.ext.UIExtension">
                        <field name="type">
                            <string>org.exoplatform.ecm.dms.UIECMAdminControlPanel</string>
                        </field>
                        <field name="name">
                            <string>CacheView</string>
                        </field>
                        <field name="category">
                            <string>GlobalAdministration</string>
                        </field>
                        <field name="component">
                            <string>org.exoplatform.wcm.component.cache.UIWCMCacheComponent</string>
                        </field>
                    </object>
                </object-param>
                <object-param>
                    <name>UIWCMCacheManager</name>
                    <object type="org.exoplatform.webui.ext.UIExtension">
                        <field name="type">
                            <string>org.exoplatform.ecm.dms.UIECMAdminControlPanel</string>
                        </field>
                        <field name="name">
                            <string>UIWCMCacheManager</string>
                        </field>
                        <field name="category">
                            <string>GlobalAdministration</string>
                        </field>
                        <field name="component">
                            <string>org.exoplatform.wcm.manager.cache.UIWCMCacheManagerComponent</string>
                        </field>
                        <field name="extendedFilters">
                            <collection type="java.util.ArrayList">
                                <value>
                                    <object type="org.exoplatform.webui.ext.filter.impl.UserACLFilter">
                                        <field name="permissions">
                                            <collection item-type="java.lang.String" type="java.util.ArrayList">
                                                <value>
                                                    <string>*:/platform/administrators</string>
                                                </value>
                                            </collection>
                                        </field>
                                    </object>
                                </value>
                            </collection>
                        </field>
                    </object>
                </object-param>
            </init-params>
        </component-plugin>
    </external-component-plugins>
</configuration>

Note

With this configuration, only the users with the *:/platform/administrators membership have the right to access the CacheView item.

2. Launch mvn clean install.

3. Copy the resource bundle.

Note

All resources can be located in the src/main/resource package because the resources (*.xml, images, conf file) and the code are separated. This is very useful in a hierarchical structure.

Create ExamplePortlet_en.xml with the following content and add it to the src/main/resource package:




<bundle>
    <!-- ################################################################################ # org.exoplatform.wcm.component.cache.UIWCMCacheForm
  # ################################################################################ -->

    <UIWCMCacheForm>
        <action>
            <Cancel>Cancel</Cancel>
            <Save>Save</Save>
            <Clear>Clear the cache</Clear>
        </action>
        <label>
            <maxsize>Max size :</maxsize>
            <livetime>Live time in sec :</livetime>
            <isCacheEnable>Cache enabled(should always be on production enviroment)</isCacheEnable>
            <hit>Hit count :</hit>
            <currentSize>Current size</currentSize>
            <miss>Miss count :</miss>
        </label>
    </UIWCMCacheForm>

    <!-- ################################################################################ # org.exoplatform.wcm.manager.cache.UIWCMCacheManagerForm
  # ################################################################################ -->

    <UIWCMCacheManagerForm>
        <action>
            <Cancel>Cancel</Cancel>
            <Save>Save</Save>
            <Clear>Clear the cache</Clear>
        </action>
        <label>
            <cacheModify>Cache to modify :</cacheModify>
            <maxsize>Max size :</maxsize>
            <livetime>Live time in sec :</livetime>
            <isCacheEnable>Cache enabled(should always be on production enviroment)</isCacheEnable>
            <hit>Hit count :</hit>
            <currentSize>Current size</currentSize>
            <miss>Miss count :</miss>
        </label>
    </UIWCMCacheManagerForm>

    <UIECMAdminControlPanel>
        <tab>
            <label>
                <GlobalAdministration>Global Administration</GlobalAdministration>
            </label>
        </tab>
        <label>
            <UIWCMCache>WCM Cache</UIWCMCache>
            <UIWCMCachePanel>WCM Cache Administration</UIWCMCachePanel>
            <UIWCMCacheManager>Managing Caches</UIWCMCacheManager>
            <UIWCMCacheManagerPanel>WCM Cache Management</UIWCMCacheManagerPanel>
        </label>
    </UIECMAdminControlPanel>
</bundle>

You must add the following content to configuration.xml to register the resource bundle.

Note

By being added this configuration, the resource bundle has been completely separated from the original system. This is clearly useful for you to get an independent plugin.



<external-component-plugins>
    <!-- The full qualified name of the ResourceBundleService -->
    <target-component>org.exoplatform.services.resources.ResourceBundleService</target-component>
    <component-plugin>
        <!-- The name of the plugin -->
        <name>ResourceBundle Plugin</name>
        <!-- The name of the method to call on the ResourceBundleService in order to register the ResourceBundles -->
        <set-method>addResourceBundle</set-method>
        <!-- The full qualified name of the BaseResourceBundlePlugin -->
        <type>org.exoplatform.services.resources.impl.BaseResourceBundlePlugin</type>
        <init-params>
            <values-param>
                <name>init.resources</name>
                <description>Store the following resources into the db for the first launch</description>
                <value>locale.portlet.cache.ExamplePortlet</value>
            </values-param>
            <values-param>
                <name>portal.resource.names</name>
                <description>The properties files of the portal , those file will be merged
                    into one ResoruceBundle properties
                </description>
                <value>locale.portlet.cache.ExamplePortlet</value>
            </values-param>
        </init-params>
    </component-plugin>
</external-component-plugins>