« Back

Adding the workflow portlets to a page

Staff Blogs August 30, 2011 By Juan Fernández Staff

 

Hi all! 
In a recent project I had to add these portlets ("My Workflow Tasks" and "My Submissions") to a normal user page. By default they are shown in the control panel, but depending on your project needs you may want to use them elsewhere. Here are the steps you need to achieve this easily.
 
Basically you need three things:
 
  • Remove them from the control panel
  • Add them to the "Add Applications" menu
  • Add "ADD_TO_PAGE" permissions
 
To do this you need an ext plugin (which you can create in the liferay plugins sdk via <<create my-ext "my ext">> command)
 
Once you have your ext plugin ready in your plugins sdk, go to your-ext/docroot/WEB-INF/ext-web/docroot/WEB-INF
 
in your-ext/docroot/WEB-INF/ext-web/docroot/WEB-INF/liferay-portlet-ext.xml add this (this is the original content minus the control panel classes configuration)
 
<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.0.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_0_0.dtd">
 
<liferay-portlet-app>
<portlet>
<portlet-name>153</portlet-name>
<icon>/html/icons/my_workflow_tasks.png</icon>
<struts-path>my_workflow_tasks</struts-path>
<portlet-url-class>com.liferay.portal.struts.StrutsActionPortletURL</portlet-url-class>
<use-default-template>false</use-default-template>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>50</render-weight>
<header-portlet-css>/html/portlet/asset_publisher/css/main.jsp</header-portlet-css>
<header-portlet-css>/html/portlet/enterprise_admin/css/main.jsp</header-portlet-css>
<header-portlet-css>/html/portlet/workflow_definitions/css/main.jsp</header-portlet-css>
<css-class-wrapper>portlet-workflow-tasks</css-class-wrapper>
</portlet>
<portlet>
<portlet-name>158</portlet-name>
<icon>/html/icons/my_workflow_instances.png</icon>
<struts-path>my_workflow_instances</struts-path>
<portlet-url-class>com.liferay.portal.struts.StrutsActionPortletURL</portlet-url-class>
<use-default-template>false</use-default-template>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>50</render-weight>
<header-portlet-css>/html/portlet/asset_publisher/css/main.jsp</header-portlet-css>
<header-portlet-css>/html/portlet/enterprise_admin/css/main.jsp</header-portlet-css>
<header-portlet-css>/html/portlet/workflow_definitions/css/main.jsp</header-portlet-css>
<css-class-wrapper>portlet-workflow-instances</css-class-wrapper>
</portlet>
</liferay-portlet-app>
 
in your-ext/docroot/WEB-INF/ext-web/docroot/WEB-INF/liferay-display.xml remove
<portlet id="153" />
<portlet id="158" />
from hidden category and add them to another one (the one which you prefer!)
 
In your-ext/docroot/WEB-INF/ext-impl/src/resource-actions/workflow.xml, add this (which is the original workflow.xml after deleting ACCESS_IN_CONTROL_PANEL permission and adding ADD_TO_PAGE):
 
...
<portlet-name>153</portlet-name>
<permissions>
<supports>
<action-key>ADD_TO_PAGE</action-key>
<action-key>CONFIGURATION</action-key>
<action-key>VIEW</action-key>
</supports>
...
<portlet-name>158</portlet-name>
<permissions>
<supports>
<action-key>ADD_TO_PAGE</action-key>
<action-key>CONFIGURATION</action-key>
<action-key>VIEW</action-key>
</supports>
...
 
 
When you're done, run ant deploy and restart your application server. 
And that's it! I hope I helped you
Regards, 
Juan Fernández

 

Threaded Replies Author Date
Hey Juan, If i understand you correctly your... Jelmer Kuperus August 30, 2011 5:19 PM
Great job! Thanks Juan. Giang (Jiang) Truong Khuong September 2, 2011 6:22 PM
Hi Juan, Thanks, I was stuck trying to figure... Brian Jamieson September 13, 2011 8:37 AM
Hi Brian: glad I helped you :) There's no need... Juan Fernández September 13, 2011 8:51 AM
Hi Juan, Thanks for confirming that for me. I... Brian Jamieson September 13, 2011 9:12 AM
that's it! That's the reason to use it :) Juan Fernández September 14, 2011 12:07 AM
Thanks Juan. I was trying to do the same with... Rakesh Goswami April 30, 2012 3:36 AM
Hi, I was trying to do the same thing following... Paradise Lost August 11, 2012 3:35 PM
It does even come to the application list. Paradise Lost August 11, 2012 3:36 PM
any help/suggestion pls? Paradise Lost August 12, 2012 1:39 PM
[...] Hello everyone, I have followed this blog... Anonymous August 15, 2012 1:27 AM
Great post. Thanks a lot..! Vishal Panchal September 6, 2012 5:43 AM
Hi, I tried implementing the above steps for... Satya Bhat September 26, 2012 4:07 AM
i don't have liferay-display.xml and... Enrico Maria Rossi February 1, 2013 7:03 AM

Hey Juan, If i understand you correctly your approach relies on your ext-impl jar being loaded before the portal-impl jar. While this would work in tomcat (i believe it loads the jars in web-inf/lib in alphabetical order) judging by some posts on the forum, this isn't always the case on other application servers. As far as i know the servlet spec does not cover the loading order so your milage may vary
Posted on 8/30/11 5:19 PM.
Great job!
Thanks Juan.
Posted on 9/2/11 6:22 PM.
Hi Juan,

Thanks, I was stuck trying to figure how to close the loop with the ADD_TO_PAGE part. You have really helped me out here!

Can I ask, is there any specific reason why you need to remove the portlets from the control panel when you add them to a normal page?
Posted on 9/13/11 8:37 AM.
Hi Brian:
glad I helped you emoticon
There's no need to remove the permissions: that was my requirement, but it is not mandatory
Regards!
Posted on 9/13/11 8:51 AM in reply to Brian Jamieson.
Hi Juan,

Thanks for confirming that for me.

I had tried using a hook plugin to override the settings, but couldn't find the equivalent of 'WEB-INF/ext-impl/src/resource-actions/workflow.xml' to override.

Is that why you made an EXT plugin ?
Posted on 9/13/11 9:12 AM in reply to Juan Fernández.
that's it! That's the reason to use it emoticon
Posted on 9/14/11 12:07 AM in reply to Brian Jamieson.
Thanks Juan.
I was trying to do the same with ext and this blog helps.
Posted on 4/30/12 3:36 AM.
Hi,
I was trying to do the same thing following this post but did not work for me , i am using Liferay 6.1+. Build a ext using maven. Please suggest ...is there any special change in 6.1 ?

Thanks
Rony.
Posted on 8/11/12 3:35 PM in reply to Rakesh Goswami.
It does even come to the application list.
Posted on 8/11/12 3:36 PM in reply to Paradise Lost.
any help/suggestion pls?
Posted on 8/12/12 1:39 PM in reply to Paradise Lost.
[...] Hello everyone, I have followed this blog and its not working on the latest Liferay 6.1 CE GA2. If I do it aggresively by editting liferay-display.xml and liferay-portlet.xml its working, however I... [...] Read More
Posted on 8/15/12 1:27 AM.
Great post.
Thanks a lot..!
Posted on 9/6/12 5:43 AM in reply to .
Hi,

I tried implementing the above steps for user admin portlet.But as soon as i do ant direct-deploy i get this error as" Duplicate struts path users_admin" and "NoSuchResourceActionException: 125#add_to_page"..This is my entry in portal.xml under resource-action:
<portlet-resource>
<portlet-name>125</portlet-name>
<permiss­ions>
<supports>
<action-key>ADD_TO_PAGE</action-key>
<ac­tion-key>CONFIGURATION</action-key>
<action-key>EXPORT_USER</action-key­>
<action-key>VIEW</action-key>
</supports>
<site-member-defa­ults>
<action-key>VIEW</action-key>
</site-member-defaults>
<­guest-defaults>
<action-key>VIEW</action-key>
</guest-defaults>
­ <guest-unsupported>
<action-key>ACCESS_IN_CONTROL_PANEL</action-key>
­ <action-key>CONFIGURATION</action-key>
</guest-unsupported>
</permi­ssions>
</portlet-resource>
--------------------------------------
and liferay-portlet-ext.xml goes as :
<portlet>
<portlet-name>125</portlet-name>
<icon>/html/icons/users_admin.png</icon>
­ <struts-path>users_admin</struts-path>
<indexer-class>com.liferay.portlet.use­rsadmin.util.OrganizationIndexer</indexer-class>
<indexer-class>com.liferay.po­rtlet.usersadmin.util.UserIndexer</indexer-class>
<portlet-url-class>com.lifer­ay.portal.struts.StrutsActionPortletURL</portlet-url-class>
<atom-collection-a­dapter>com.liferay.portlet.usersadmin.atom.UserAtomCollectionAdapter</atom-colle­ction-adapter>
<custom-attributes-display>com.liferay.portlet.usersadmin.Layou­tCustomAttributesDisplay</custom-attributes-display>
<custom-attributes-displa­y>com.liferay.portlet.usersadmin.OrganizationCustomAttributesDisplay</custom-att­ributes-display>
<custom-attributes-display>com.liferay.portlet.usersadmin.Use­rCustomAttributesDisplay</custom-attributes-display>
<use-default-template>fal­se</use-default-template>
<private-request-attributes>false</private-request-a­ttributes>
<private-session-attributes>false</private-session-attributes>
<r­ender-weight>50</render-weight>
<header-portlet-css>/html/portlet/layouts_admi­n/css/main.css</header-portlet-css>
<header-portlet-css>/html/portlet/users_ad­min/css/main.css</header-portlet-css>
<css-class-wrapper>portlet-users-admin</­css-class-wrapper>
</portlet>
------------------------------------------------
ple­ase suggest...

Thanks,
Satya
Posted on 9/26/12 4:07 AM.
i don't have liferay-display.xml and workflow.xml in my ext-project. why? thanks.
Posted on 2/1/13 7:03 AM.