This recipe explains how to attach applications to a page using the XML configuration of GateIn.
Let's assume that you have defined the page as the previous recipe in the same file:
02portal.war/WEB-INF/conf/portal/portal/financials/page.xml
In order to set specific portlets in a page, you need to declare a portlet-application
element for each portlet instance you want to use:
<page> <name>contactus</name> <title>Contact us</title> <access-permissions>Everyone</access-permissions> <edit-permission>*:/platform/administrators</edit-permission> <portlet-application> <portlet> <application-ref>web</application-ref> <portlet-ref>ContactUsPortlet</portlet-ref> <preferences> <preference> <name>useAJAX</name> <value>false</value> <read-only>false</read-only> </preference> </preferences> </portlet> <title>Contact us</title> <access-permissions>Everyone</access-permissions> <show-info-bar>false</show-info-bar> </portlet-application> </page>
In this XML definition, we have added a new portlet that contains the ContactUsPortlet
previously added in the Application Registry, as we have seen in Chapter 2, Managing Portal Contents Using the GUI. We have assumed that this portlet exists in the Application Registry.
A portlet can be declared using a portlet-application
element in a page
definition; this means that you have to provide the following sub-elements inside the snippet:
application-ref
: Shows the portlet category as stored in the Application Registryportlet-ref
: Shows the portlet reference as stored in the Application Registrypreferences
: Properties for the current portlet instanceIn GateIn, you will find the following default values for the application-ref
element:
web
: This is the Web categoryexoadmin
: This is the Administration categorydashboard
: This is the Dashboard categoryNotice that you can use your own categories, previously created using the Application Registry.
However, this is not the only way to deploy portlets in GateIn, as a standard portlet-container, such as any portlet that would be deployed in WAR, with its WEB-INF/portlet.xml
file, can be used in a portal page. The application-ref
is then set with the name of the WebApp of the WAR. The portlet-ref
is set with the name of the portlet declared in the portlet.xml
file.
You have so far learned how to attach portlet instances in pages, but if you want to use gadgets, you need to use a different XML element
named gadget-application
.
This is an example of how to declare a gadget for a page:
<gadget-application> <gadget> <gadget-ref>ServicesManagement</gadget-ref> </gadget> <title>Services Management</title> <access-permissions>manager:/platform/administrators</access-permissions> <show-info-bar>false</show-info-bar> </gadget-application>
As you can see in the preceding definition, we already know some of the elements that were introduced for the portlet declaration: title
, access-permission
, and show-info-bar
.
The unique new element introduced here is gadget-ref
; this allows
defining the identifier of the gadget declared in the Application Registry.
If you want to add or change the default settings for application categories related to a specific portal, you can take a look at the following file to understand how to override or define the current XML components:
/02portal.war/WEB-INF/conf/portal/application-registry-configuration.xml
Let's look at the default configuration of GateIn and look at how to use these initialization scripts for your custom portal:
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd http://www.exoplaform.org/xml/ns/kernel_1_2.xsd" xmlns="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd"> . . . <component> <key>org.exoplatform.application.registry.ApplicationRegistryService</key> <type>org.exoplatform.application.registry.impl.ApplicationRegistryServiceImpl</type> <component-plugins> <component-plugin> <name>new.portal.portlets.registry</name> <set-method>initListener</set-method> <type>org.exoplatform.application.registry.ApplicationCategoriesPlugins</type> <description>this listener init the portlets are registered in PortletRegister</description> <init-params> <object-param> <name>administration</name> <description>description</description> <object type="org.exoplatform.application.registry.ApplicationCategory"> <field name="name"> <string>Administration</string> </field> <field name="displayName"> <string>Administration</string> </field> <field name="description"> <string>application for administration</string> </field> <field name="accessPermissions"> <collection type="java.util.ArrayList" item-type="java.lang.String"> <value> <string>*:/platform/administrators</string> </value> <value> <string>*:/organization/management/executive-board</string> </value> </collection> </field> . . . </configuration>
The preceding snippet shows how GateIn declares the creation of the default Administration
category and sets the access permissions and all the applications that must be included.
To define a new category we therefore need to provide:
ApplicationRegistry
class that we want to use; if you want, you can use the default one provided by GateIn. To identify a component in the configuration engine, you have to set the key
and the type
element.ApplicationCategoriesPlugin
because it is the responsible class for creating categories during the first execution of the portal instance.init-params
element that contains for each category a specific object-param
element.name
: This is the node name for the categorydisplayName
: The label of the categorydescription
: This is the description for the current categoryaccessPermission
: The permissions for accessing applications defined for this categoryapplications
: The list of all the applications (portlets or gadgets) that we want to initialize under this categoryAn application must be declared in a category definition in the following way:
<field name="applications"> <collection type="java.util.ArrayList"> <value> <object type="org.exoplatform.application.registry.Application"> <field name="applicationName"> <string>ApplicationRegistryPortlet</string> </field> <field name="categoryName"> <string>administration</string> </field> <field name="displayName"> <string>Application Registry</string> </field> <field name="description"> <string>Application Registry</string> </field> <field name="type"> <string>portlet</string> </field> <field name="contentId"> <string>exoadmin/ApplicationRegistryPortlet</string> </field> <field name="accessPermissions"> <collection type="java.util.ArrayList" item-type="java.lang.String"> <value> <string>*:/platform/administrators</string> </value> <value> <string>*:/organization/management/executive-board</string> </value> </collection> </field> </object> </value>
Finally, let's look at all the needed elements to initialize an application under a category:
applicationName
: The name of the application instance as registered in the Application RegistrycategoryName
: The name of the categorydisplayName
: The default label to use for the current applicationdescription
: The description for the applicationtype
: The type of the implementation; the value could be portlet
or gadget
contentId
: The identifier of the application definition in the portal instanceaccessPermissions
: The permissions to access the current application3.133.141.219