RE: Liferay 7.0 Override JournalDisplayContext.java

Carmine Azzaro, modified 6 Years ago. New Member Post: 1 Join Date: 11/14/18 Recent Posts

Hi,

 

goal to achive: default order descending in web content portlet

I tried to do this by overriding (module fragment project) toolbar.jsp but here i'm not able to modify the variable journalDisplayContext

So i need to override the JournalDisplayContext.java to set the default order to "desc", or is there any other way to achive my goal?

 

Thanks very much

Jibin Johnson, modified 6 Years ago. New Member Posts: 4 Join Date: 3/14/18 Recent Posts
Hello Carmine Azzaro,

I am also looking for a way to override JournalDisplayContext.java class through an extension module, meanwhile here's a working approach1. Override JSP of com.liferay.journal.web
2. You check current orderByType value for null
if (ParamUtil.getString(request, "orderByType")==null) {
    PortletPreferencesFactoryUtil.getPortalPreferences(liferayPortletRequest).setValue("com_liferay_journal_web_portlet_JournalPortlet", "order-by-type", "desc");
}

meanwhile if you have find a way to override the JournalDisplayContext.java then do share it.