Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Loïc Dumont
Hide a portlet on runtime
October 10, 2012 11:57 PM
Answer

Loïc Dumont

Rank: Junior Member

Posts: 43

Join Date: April 27, 2010

Recent Posts

I'm developing a custom portlet to display files from a specific folder.

I have a requirement to hide the portlet if there is no file to display.

From what I understant of Liferay and portlets it's not possible within the java class or jsps of the portlet to hide the portlet on runtime.

I tried with javascript (alloy ui) but the problem is that the portlet shows up and then hide. In css I will not be able to hide the whole portlet.

So I guess I need to modify my Velocity templates to check before displaying the portlet but if you have a better solution, I would love to hear it...

Thanks
Bart Simpson
RE: Hide a portlet on runtime
October 11, 2012 12:37 AM
Answer

Bart Simpson

Rank: Liferay Master

Posts: 523

Join Date: August 29, 2011

Recent Posts

In css I will not be able to hide the whole portlet.


Check the class that is applied on WCD (web content display), I suppose you want to achive something similar. Eg when there is no journal article selected , the portlet is displayed in a different way, and it's hidden when you toggle controls by docbar checkbox
Oliver Bayer
RE: Hide a portlet on runtime
October 11, 2012 1:33 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 875

Join Date: February 18, 2009

Recent Posts

Hi Loic,

if I don't misunderstood Bart he is referring to the "semi-transparent" look of the journal portlet (folder: "html \ portlet \ journal_content"). You can achieve this by adding the following line into your view.jsp if there aren't any search results:
1renderRequest.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY, Boolean.TRUE);

HTH Oli
Bart Simpson
RE: Hide a portlet on runtime
October 11, 2012 1:52 AM
Answer

Bart Simpson

Rank: Liferay Master

Posts: 523

Join Date: August 29, 2011

Recent Posts

Oliver Bayer:
Hi Loic,

if I don't misunderstood Bart he is referring to the "semi-transparent" look of the journal portlet (folder: "html \ portlet \ journal_content"). You can achieve this by adding the following line into your view.jsp if there aren't any search results:
1renderRequest.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY, Boolean.TRUE);

HTH Oli



Indeed I was referring to the same, Thanks for the code emoticon
Loïc Dumont
RE: Hide a portlet on runtime
October 11, 2012 2:51 AM
Answer

Loïc Dumont

Rank: Junior Member

Posts: 43

Join Date: April 27, 2010

Recent Posts

Thanks to both of you, this works perfectly !

Thanks again!