Introduction:-
To instantiate My account portlet in our portal. There is a bit different approach to follow than in the other version of liferay
(Ref:- http://issues.liferay.com/browse/LPS-33940?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel)
Note:- It is assumed that the system is set up with Liferay 6.1 tomcat bundle and eclipse is configured with the same sdk
Steps:-
1. Create an ext plugin.
i) In Eclipse(Liferay developer studio) Go to New->Liferay Project
ii) In the "New Liferay Project" dialog. Write the "Project Name:" (e.g MyPortal)
iii) Select "Plugin" type as ext.
iv) Press the "Finish" button.
2. In your MyPortal-ext/docroot/WEB-INF/ext-web/docroot/WEB-INF/liferay-portlet-ext.xml. Write the following code
<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.1.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_1_0.dtd">
<liferay-portlet-app>
<portlet>
<portlet-name>2</portlet-name>
<system>false</system>
</portlet>
</liferay-portlet-app>
(Explanation :-
system
3. Add following code to MyPortal-ext/docroot/WEB-INF/ext-web/docroot/WEB-INF/portlet-ext.xml.
<?xml version="1.0"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
version="2.0">
<portlet>
<portlet-name>2</portlet-name>
<display-name>My Account</display-name>
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
<init-param>
<name>template-path</name>
<value>/html/portlet/my_account/</value>
</init-param>
<init-param>
<name>view-action</name>
<value>/my_account/edit_user</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
</portlet>
</portlet-app>
Note:- Below 2 steps (4 and 5) are followed for Liferay 6.1 GA
4. Create a folder under portal-ext/docroot/WEB-INF/ext-impl/src/ as "resource-actions"
and a file inside this folder
portal-ext/docroot/WEB-INF/ext-impl/src/resource-actions/portal-ext.xml
5. Add the below code to the file:-
<?xml version="1.0"?>
<!DOCTYPE resource-action-mapping PUBLIC "-//Liferay//DTD Resource Action Mapping 6.1.0//EN" "http://www.liferay.com/dtd/liferay-resource-action-mapping_6_1_0.dtd">
<resource-action-mapping>
<portlet-resource>
<portlet-name>2</portlet-name>
<permissions>
<supports>
<action-key>ADD_TO_PAGE</action-key>
<action-key>ACCESS_IN_CONTROL_PANEL</action-key>
<action-key>CONFIGURATION</action-key>
<action-key>VIEW</action-key>
</supports>
<site-member-defaults />
<guest-defaults />
<guest-unsupported>
<action-key>ADD_TO_PAGE</action-key>
<action-key>ACCESS_IN_CONTROL_PANEL</action-key>
<action-key>CONFIGURATION</action-key>
<action-key>VIEW</action-key>
</guest-unsupported>
</permissions>
</portlet-resource>
</resource-action-mapping>
6. In portal-ext.properties add dockbar.add.portlets=2,56,101,110,71
7. Deploy your ext.
8. Reboot the server.
Result:
You'll be able to view "My Account portlet" in the dockbar "Add"->more-> Tools menu
To instantiate My account portlet in our portal. There is a bit different approach to follow than in the other version of liferay
(Ref:- http://issues.liferay.com/browse/LPS-33940?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel)
Note:- It is assumed that the system is set up with Liferay 6.1 tomcat bundle and eclipse is configured with the same sdk
Steps:-
1. Create an ext plugin.
i) In Eclipse(Liferay developer studio) Go to New->Liferay Project
ii) In the "New Liferay Project" dialog. Write the "Project Name:" (e.g MyPortal)
iii) Select "Plugin" type as ext.
iv) Press the "Finish" button.
2. In your MyPortal-ext/docroot/WEB-INF/ext-web/docroot/WEB-INF/liferay-portlet-ext.xml. Write the following code
<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.1.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_1_0.dtd">
<liferay-portlet-app>
<portlet>
<portlet-name>2</portlet-name>
<system>false</system>
</portlet>
</liferay-portlet-app>
(Explanation :-
system
- Set the system value to true if the portlet is a system portlet that a user cannot manually add to their page. The default value is false.
3. Add following code to MyPortal-ext/docroot/WEB-INF/ext-web/docroot/WEB-INF/portlet-ext.xml.
<?xml version="1.0"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
version="2.0">
<portlet>
<portlet-name>2</portlet-name>
<display-name>My Account</display-name>
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
<init-param>
<name>template-path</name>
<value>/html/portlet/my_account/</value>
</init-param>
<init-param>
<name>view-action</name>
<value>/my_account/edit_user</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
</portlet>
</portlet-app>
Note:- Below 2 steps (4 and 5) are followed for Liferay 6.1 GA
4. Create a folder under portal-ext/docroot/WEB-INF/ext-impl/src/ as "resource-actions"
and a file inside this folder
portal-ext/docroot/WEB-INF/ext-impl/src/resource-actions/portal-ext.xml
5. Add the below code to the file:-
<?xml version="1.0"?>
<!DOCTYPE resource-action-mapping PUBLIC "-//Liferay//DTD Resource Action Mapping 6.1.0//EN" "http://www.liferay.com/dtd/liferay-resource-action-mapping_6_1_0.dtd">
<resource-action-mapping>
<portlet-resource>
<portlet-name>2</portlet-name>
<permissions>
<supports>
<action-key>ADD_TO_PAGE</action-key>
<action-key>ACCESS_IN_CONTROL_PANEL</action-key>
<action-key>CONFIGURATION</action-key>
<action-key>VIEW</action-key>
</supports>
<site-member-defaults />
<guest-defaults />
<guest-unsupported>
<action-key>ADD_TO_PAGE</action-key>
<action-key>ACCESS_IN_CONTROL_PANEL</action-key>
<action-key>CONFIGURATION</action-key>
<action-key>VIEW</action-key>
</guest-unsupported>
</permissions>
</portlet-resource>
</resource-action-mapping>
6. In portal-ext.properties add dockbar.add.portlets=2,56,101,110,71
7. Deploy your ext.
8. Reboot the server.
Result:
You'll be able to view "My Account portlet" in the dockbar "Add"->more-> Tools menu