Last updated by michael.berg 2 years ago
Overview
This plugin inherits
Portlets Plugin, and
add
Liferay Portal specific configurations and adapters.
Please see the
Portlets Plugin document for
the common usage, and this document describes only Liferay Portal specific
topics.
This plugin has tested with Liferay Portal 5.2.2, but it uses DTD for version
5.1 so I hope it works with LP 5.1.X.
History
Version 0.2
- Use Dependency Management features introduced in Grails 1.2
- Supports portlets created in packages (portlets plugin version 0.8 is required for this to fully work)
- Correct grouping and categorization of portlets in liferay-display.xml
Version 0.1
Configuration
This plugin reads the configuration form portlet class and Config.groovy and
generates "liferay-display.xml", "liferay-portlet.xml", and
"liferay-plugin-package.properties" under "WEB-INF".
import javax.portlet.*class MyFirstPortlet { def title = 'Portlet Title'
def description = '''
Description about the portlet goes here.
'''
def displayName = 'Display Name'
def supports = ['text/html':['view', 'edit', 'help']] // DEFINITIONS FOR liferay-display.xml
def liferay_display_category = 'MyCategory' // DEFINITIONS FOR liferay-portlets.xml
def liferay_portlet_ajaxable = 'true'
def liferay_portlet_header_portlet_css = [
'/css/protoFlow.css'
]
def liferay_portlet_header_portlet_javascript = [
'/plugins/richui-0.5/js/flow/lib/prototype.js',
'/plugins/richui-0.5/js/flow/lib/scriptaculous.js',
'/plugins/richui-0.5/js/reflection/reflection.js',
'/plugins/richui-0.5/js/flow/protoFlow.js'
]..."role-mapper" and "custom-user-attribute" elements can be defined in
"grails-app/conf/Config.groovy".
liferay {
portlet_role_mappers = ['administrator':'myadmin', 'guest':'myguest']
//portlet_custom_user_attributes = ['foo':'com.example.bar.Baz']
plugin_package {
name = "${appName}"
module_group_id = 'MyModule'
module_incremental_version = '1'
tags='sample'
short_description='a short description'
change_log=''
page_uri=''
author='Kenji Nakamura'
license='Proprietary'
}
}The snippet above generates the following liferay-portlet.xml.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 5.1.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_5_1_0.dtd">
<!--GENERATED BY GRAILS PORTLETS PLUGIN - DO NOT EDIT AND CONFIGURE IN PORTLET groovy-->
<liferay-portlet-app>
<portlet>
<portlet-name>MyFirst</portlet-name>
<ajaxable>true</ajaxable>
<header-portlet-css>/css/protoFlow.css</header-portlet-css>
<header-portlet-javascript>/plugins/richui-0.5/js/flow/lib/prototype.js</header-portlet-javascript>
<header-portlet-javascript>/plugins/richui-0.5/js/flow/lib/scriptaculous.js</header-portlet-javascript>
<header-portlet-javascript>/plugins/richui-0.5/js/reflection/reflection.js</header-portlet-javascript>
<header-portlet-javascript>/plugins/richui-0.5/js/flow/protoFlow.js</header-portlet-javascript>
</portlet>
<role-mapper>
<role-name>administrator</role-name>
<role-link>myadmin</role-link>
</role-mapper>
<role-mapper>
<role-name>guest</role-name>
<role-link>myguest</role-link>
</role-mapper>
</liferay-portlet-app>liferay-display.xml looks like this.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 5.1.0//EN" "http://www.liferay.com/dtd/liferay-display_5_1_0.dtd">
<!--GENERATED BY GRAILS PORTLETS PLUGIN - DO NOT EDIT AND CONFIGURE IN PORTLET groovy-->
<display>
<category name='MyCategory'>
<portlet id='MyFirst'/>
</category>
</display>This also generate liferay-plugin-package.properties.
#This is generated by Grails. The changes will be overwritten. Edit 'liferay.grails-app/conf/Config.groovy.
#Tue May 19 20:49:13 PDT 2009
change-log=
module-incremental-version=1
name=liferay1
page-uri=
author=Kenji Nakamura
license=Proprietary
module-group-id=MyModule
short-description=a short description
liferay-display.xml
You can define the elements for liferay-display.xml as a form of field in
portlet class with "liferay_display_" prefix.
The element you can specify is "liferay_display_category" only.
liferay-portlet.xml
You can define the elements for liferay-portlets.xml as a form of field in
portlet class with "liferay_portlet_" prefix.
For the elements which cardinality is more than one, you can specify the list as
the value.
The elements you can specify are
'icon', 'virtual_path', 'struts_path',
'configuration_path', 'configuration_action_class', 'indexer_class',
'open_search_class', 'scheduler_class', 'portlet_url_class',
'friendly_url_mapper_class', 'url_encoder_class', 'portlet_data_handler_class',
'portlet_layout_listener_class', 'pop_message_listener_class',
'social_activity_interpreter_class', 'social_request_interpreter_class',
'preferences_company_wide', 'preferences_unique_per_layout',
'preferences_owned_by_group', 'use_default_template', 'show_portlet_access_denied',
'show_portlet_inactive', 'action_url_redirect', 'restore_current_view',
'maximize_edit', 'maximize_help', 'pop_up_print', 'layout_cacheable', 'instanceable',
'user_principal_strategy', 'private_request_attributes',
'private_session_attributes', 'render_weight', 'ajaxable', 'header_portal_css',
'header_portlet_css', 'header_portal_javascript', 'header_portlet_javascript',
'footer_portal_css', 'footer_portlet_css', 'footer_portal_javascript',
'footer_portlet_javascript', 'css_class_wrapper', 'facebook_integration',
'add_default_resource', 'system', 'active', 'include'
"portlet" is automatically generated.
"role-mappers" and ""custom-user-attribute" are defined in
"grails-app/conf/Config.groovy" as the following format.
liferay {
portlet_role_mappers = ['administrator':'Administrator', 'guest':'Guest', 'power-user':'Power User', 'user':'User']
portlet_custom_user_attributes = ['foo':'org.example.Foo', 'bar':'org.example.Bar']
}
Please note that "-" (hyphens) in element name must be converted to "_"
(underscore).
liferay-plugin-package.properties
The properties in the configuration file can be specified in
"grails-app/conf/Config.groovy".
liferay {
plugin_package {
name = "${appName}"
module_group_id = 'MyModule'
module_incremental_version = '1'
tags='sample'
short_description='a short description'
change_log=''
page_uri=''
author='Kenji Nakamura'
license='Proprietary'
}
}
Please note that "-" (hyphens) in element name must be converted to "_"
(underscore).