掲示板

Need Solution

8年前 に Paramita Nandi によって更新されました。

Need Solution

New Member 投稿: 23 参加年月日: 12/03/05 最新の投稿
I am trying to import com.liferay.portal.util.WebAppPool in my custom portlet but the import can not be resolved.
I am not able to find the solution. Anyone have any idea?
thumbnail
8年前 に Jan Geißler によって更新されました。

RE: Need Solution

Liferay Master 投稿: 735 参加年月日: 11/07/05 最新の投稿
There is no solution, as you try to import a class which is not exposed vie any service jar. WebAppPool resides in portal-impl.jar which is the jar for all internal implementations. You don't have access to them in a portlet.
thumbnail
8年前 に David H Nebinger によって更新されました。

RE: Need Solution

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Paramita Nandi:
I am trying to import com.liferay.portal.util.WebAppPool in my custom portlet but the import can not be resolved.
I am not able to find the solution. Anyone have any idea?


Why?

WebAppPool really only holds the PortletCategory instances for the companies in the portal. In fact I've never heard of this class as for all the years I've been doing Liferay I've never needed it. There's likely really no reason for you to be accessing that class at all.

The fact that you need it to me indicates that you're doing something that you really shouldn't be.
thumbnail
8年前 に Jan Geißler によって更新されました。

RE: Need Solution

Liferay Master 投稿: 735 参加年月日: 11/07/05 最新の投稿
David H Nebinger:
In fact I've never heard of this class as for all the years I've been doing Liferay I've never needed it


Me too emoticon
8年前 に Paramita Nandi によって更新されました。

RE: Need Solution

New Member 投稿: 23 参加年月日: 12/03/05 最新の投稿
David H Nebinger:
Paramita Nandi:
I am trying to import com.liferay.portal.util.WebAppPool in my custom portlet but the import can not be resolved.
I am not able to find the solution. Anyone have any idea?


Why?

WebAppPool really only holds the PortletCategory instances for the companies in the portal. In fact I've never heard of this class as for all the years I've been doing Liferay I've never needed it. There's likely really no reason for you to be accessing that class at all.

The fact that you need it to me indicates that you're doing something that you really shouldn't be.



I am using com.liferay.portal.util.WebAppPool to get the category details in which a portlet is added.
<display>
<category name="category.sampleJms">
<portlet id="SampleJMS-Portlet" />
</category>
</display>


I want to get "category.sampleJms" for SampleJMS-Portlet.

Could you please suggest me any other way to do the same?
thumbnail
8年前 に David H Nebinger によって更新されました。

RE: Need Solution

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
You could do it the same way the portal does - open/parse the liferay-display.xml file and read the category.
thumbnail
8年前 に Andew Jardine によって更新されました。

RE: Need Solution

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Hey Paramita,

Try this out and see if it works for you. It's untested on my side, but I just plucked a few lines here and there from the Portal's source. Should do the trick for you.


String portletId = "my-portlet-id";
PortletBag portletBag = PortletBagPool.get(portletId);
ServletContext servletContext = portletBag.getServletContext();
String xml = HttpUtil.URLtoString(servletContext.getResource("/WEB-INF/liferay-display.xml"));
PortletCategory newPortletCategory =	PortletLocalServiceUtil.getWARDisplay(servletContextName, xml);
8年前 に Paramita Nandi によって更新されました。

RE: Need Solution

New Member 投稿: 23 参加年月日: 12/03/05 最新の投稿
Andew Jardine:
Hey Paramita,

Try this out and see if it works for you. It's untested on my side, but I just plucked a few lines here and there from the Portal's source. Should do the trick for you.


String portletId = "my-portlet-id";
PortletBag portletBag = PortletBagPool.get(portletId);
ServletContext servletContext = portletBag.getServletContext();
String xml = HttpUtil.URLtoString(servletContext.getResource("/WEB-INF/liferay-display.xml"));
PortletCategory newPortletCategory =	PortletLocalServiceUtil.getWARDisplay(servletContextName, xml);


Hi Andew,

It is not working. Category name is coming as "root" for all portlets.
I am fetching the category name using newPortletCategory .getName()
thumbnail
8年前 に Andew Jardine によって更新されました。

RE: Need Solution

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Can you share with us your code as well as the name of your project, portlet.xml and liferay-display.xml files?
8年前 に Paramita Nandi によって更新されました。

RE: Need Solution

New Member 投稿: 23 参加年月日: 12/03/05 最新の投稿
Andew Jardine:
Can you share with us your code as well as the name of your project, portlet.xml and liferay-display.xml files?


Hi

I am executing the code as groovy script from Liferay 6.2 control panel for testing. I have used portlet id of Sign in Portlet.
Hereunder is my code

import javax.servlet.ServletContext;
import com.liferay.portal.kernel.portlet.PortletBag;
import com.liferay.portal.kernel.portlet.PortletBagPool;
import com.liferay.portal.kernel.util.HttpUtil;
import com.liferay.portal.model.Portlet;
import com.liferay.portal.model.PortletCategory;
import com.liferay.portal.service.PortletLocalServiceUtil;


PortletBag portletBag = PortletBagPool.get("58");
ServletContext servletContext = portletBag.getServletContext();
def xml;
try {
xml = HttpUtil.URLtoString(servletContext.getResource("/WEB-INF/liferay-display.xml"));
PortletCategory newPortletCategory = PortletLocalServiceUtil.getWARDisplay(servletContext.getServletContextName(), xml);

out.println("Category name ="+newPortletCategory.getName());

} catch (MalformedURLException e) {

e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}