RE: Message Board portal_header.jsp override liferay 7.1

Nikhil Kapoor, modified 6 Years ago. New Member Posts: 4 Join Date: 2/2/15 Recent Posts

Hello

 

I want to overrride portal_header.jsp in message board. Tried creating jsp fragment but it isnt working. On further analysis I found that this jsp is loaded using MBPortletHeaderJSPDynamicInclude.java. Can I override this service?

 

Note: portal_header.jsp is loaded in portlet head and not in portlet body content. Can I change it?

 

Regards

Nikhil Kapoor

thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts

Hi Nikhil,

Looking at the class, I beleive you can override it if you want to -- after all, it is an OSGI Service.

 

@Component(immediate = true, service = DynamicInclude.class)
public class MBPortletHeaderJSPDynamicInclude extends BaseJSPDynamicInclude {

 

.. but, being an internal class, unless you do some OSGI tickery as David has blogged about https://community.liferay.com/blogs/-/blogs/fixing-module-package-access-modifiers you would be stuck having to make a copy of the class. It's not an ideal solution because it means that you would miss out on any future updates without manually checking for changes. 

I am confused though -- you said that you can't override the jsp with a fragment. I think you might be mistaken on that point. You should be able to, but there are two types of fragments. There is a simpler one with just the bnd references, which I presume you have tried. That will not work, as you say.

The other is overriding a portal core JSP which is used for just this type of scenario: https://dev.liferay.com/de/develop/tutorials/-/knowledge_base/7-0/overriding-core-jsps

I've done this a handful of times so that should get you what you need.

Nikhil Kapoor, modified 6 Years ago. New Member Posts: 4 Join Date: 2/2/15 Recent Posts
Hello Andrew Jardine 

 

Thanks for the response. 

 

I will try and will let you know if it works.

 

Yes actually I want to hide the search bar coming in message board portlet header which is in portlet_header.jsp file. Somehow directly creating a jsp fragment is not working. I will try with jsp bag now.

 

Regards

Nikhil Kapoor

thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts

Hi Nikhil,

 

If all you want to do is hide the search field, why don't you just taget the node with css and set the disply to be hidden?