Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to hide portlet in liferay by using javascript

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 659
    Comment on it

    When we add protlet on the page it by default set visible.

    Now, hide the portlet or set visible false using javascript.
    For this 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(
    
        /*
        This function gets loaded after each and every portlet on the page.
    
        portletId: the current portlet's id
        node: the Alloy Node object of the current portlet
        */
            function(portletId, node) {
                document.getElementById(portletId).style.display = 'none';
                // or alternatively using pure Alloy UI
                // node.hide();
            }
        );
    </aui:script>
    
    <%
    } else {
    %>
    
    <aui:script>
        Liferay.Portlet.ready(
            function(portletId, node) {
                document.getElementById(portletId).style.display = 'block';
                // or alternatively using pure Alloy UI
                // node.show();
            }
        );
    </aui:script>
    
    <%
    }
    %>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: