You can set the visibility portlet to false in the JSP using the following code:
<% renderRequest.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY, Boolean.FALSE); %>
This will hide your portlet from the user view.
Each time your portlet is displayed, you can check the parameter that was set in the request or session (your choice) to either show the portlet or not show the portlet, for example:
<% String paramFromRequestToHide = renderRequest.getParameter("hidePortlet");
Another method:
If you do not want to go with the above approach, you can combine your JavaScript approach with the parameter approach as follows:
<% String paramFromRequestToHide = renderRequest.getParameter("hidePortlet"); if (paramFromRequestToHide .equals("YES")) { %> <aui:script> Liferay.Portlet.ready( function(portletId, node) { document.getElementById(portletId).style.display = 'none';
If you want to check out the Alloy API and some of the demos to learn Alloy UI starting with Liferay 6.1, Alloy UI is the de facto javascript library for liferay. Alloy now has an official website with many useful tutorials and examples.
Hope this gives you enough material to continue :-)
source share