« Back

Adding the workflow portlets to a page

August 30, 2011 By Juan Fernández

 

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

 

Showing 7 Comments

jelmer kuperus
8/30/11 5:19 PM

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

Giang (Jiang) Truong Khuong
9/2/11 6:22 PM

Great job!
Thanks Juan.

Brian Jamieson
9/13/11 8:37 AM

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?

Juan Fernández
9/13/11 8:51 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!

Brian Jamieson
9/13/11 9:12 AM

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 ?

Juan Fernández
9/14/11 12:07 AM

that's it! That's the reason to use it emoticon

Rakesh Goswami
4/30/12 3:36 AM

Thanks Juan.
I was trying to do the same with ext and this blog helps.