Forums de discussion

LayoutLister resolves to a package

Jan Tošovský, modifié il y a 12 années.

LayoutLister resolves to a package

Liferay Master Publications: 565 Date d'inscription: 22/07/10 Publications récentes
Hello Everyone,

when slightly modifying site map portlet (via PluginsSDK) I cannot configure it properly as there are errors in the configuration page.
If this code is used:
<%@ page import="com.liferay.portal.util.LayoutLister"%>

it produces this error: Only a type can be imported. com.liferay.portal.util.LayoutLister resolves to a package

According to some tips on the web I specify that package path directly:
String redirect = ParamUtil.getString(request, "redirect");
com.liferay.portal.util.LayoutLister layoutLister = new com.liferay.portal.util.LayoutLister();
String rootNodeName = StringPool.BLANK;
com.liferay.portal.util.LayoutView layoutView = layoutLister.getLayoutView(layout.getGroupId(), layout.isPrivateLayout(), rootNodeName, locale);

But in this case I am getting another error:
com.liferay.portal.util.LayoutLister cannot be resolved to a type.

There are many other references, but without these problems.

Any idea?

Regards,
Jan
thumbnail
jelmer kuperus, modifié il y a 12 années.

RE: LayoutLister resolves to a package

Liferay Legend Publications: 1191 Date d'inscription: 10/03/10 Publications récentes
It is tomcat's cryptic way of telling you that it cannot find the class com.liferay.portal.util.LayoutLister

LayoutLister is located in portal-impl.jar and as such isn't available to sdk portlets
Jan Tošovský, modifié il y a 12 années.

RE: LayoutLister resolves to a package

Liferay Master Publications: 565 Date d'inscription: 22/07/10 Publications récentes
Thanks a lot for explanation!
So as the site map portlet is the core portlet, it can access these classes without problems.
But is there any way how to add this functionality to my portlet as well?
thumbnail
jelmer kuperus, modifié il y a 12 années.

RE: LayoutLister resolves to a package

Liferay Legend Publications: 1191 Date d'inscription: 10/03/10 Publications récentes
You could use the portalclassinvoker see : http://www.liferay.com/community/forums/-/message_boards/message/8931877
Jan Tošovský, modifié il y a 12 années.

RE: LayoutLister resolves to a package

Liferay Master Publications: 565 Date d'inscription: 22/07/10 Publications récentes
Sounds promising. But I am a bit lost.
Here is the original code I'd like to reuse:
LayoutLister layoutLister = new LayoutLister();

String rootNodeName = StringPool.BLANK;
LayoutView layoutView = layoutLister.getLayoutView(layout.getGroupId(), layout.isPrivateLayout(), rootNodeName, locale);

List layoutList = layoutView.getList();


Both LayoutLister and LayoutView are in portal-impl.jar
String rootNodeName = StringPool.BLANK;
final String DELEGATE_CLASS_NAME_LISTER = "com.liferay.portal.util.LayoutLister";
final String DELEGATE_CLASS_NAME_VIEW = "com.liferay.portal.util.LayoutView";

MethodKey keyView = new MethodKey(DELEGATE_CLASS_NAME_LISTER, "getLayoutView", long.class, boolean.class, String.class, Locale.class);
Object layoutView = PortalClassInvoker.invoke(false, keyView, layout.getGroupId(), layout.isPrivateLayout(), rootNodeName, locale);

MethodKey keyList = new MethodKey(DELEGATE_CLASS_NAME_VIEW, "getList", new String[0]);
List layoutList = (List) PortalClassInvoker.invoke(false, keyList);

Seems to be maybe too naive. I am getting NullPointerException
at com.liferay.portal.kernel.util.MethodHandler.invoke(MethodHandler.java:81)
at com.liferay.portal.kernel.util.MethodHandler.invoke(MethodHandler.java:75)
at com.liferay.portal.kernel.util.PortalClassInvoker.invoke(PortalClassInvoker.java:42)
...