论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
Suresh Nimmakayala
can we import classes from one pluginsdk portlet to another ?
2012年5月6日 下午7:05
答复

Suresh Nimmakayala

等级: Liferay Master

帖子: 564

加入日期: 2004年8月17日

最近的帖子

Hi all,

may be simple but i am unable to access

1. i write a custom plugin-sdk -portlet using Liferay developer studio(6.1EE), for example this portlet can do the parsing custom xml files using a class com.sparser.sax.MySAXParserBean

2.how can i able to access com.sparser.sax.MySAXParserBean from the above plugin portlet to another plugin portlet ,in new portlet also i want to parsing the xml file i dont want to duplicate same class in the all other portlets

other plugins i am trying using import ?
<%@ page import="com.sparser.sax.*" %>
Error in stack trace:
Only a type can be imported. com.sparser.sax.MySAXParserBean resolves to a package
MySAXParserBean cannot be resolved to a type

i tried properties -- Project References added other plugin portlet still no use,

please anyone can suggest regarding creating a class in one portlet, can we reuse in other plugin portlets?


Regards
Suresh
David H Nebinger
RE: can we import classes from one pluginsdk portlet to another ?
2012年5月6日 下午8:13
答复

David H Nebinger

等级: Liferay Legend

帖子: 7008

加入日期: 2006年9月1日

最近的帖子

You cannot do this. They are separate war files and have separate class loaders.

Your only option is to create an EXT plugin. Code in the EXT plugin can be pulled into plugin projects the same way you can access portal jars.
Suresh Nimmakayala
RE: can we import classes from one pluginsdk portlet to another ?
2012年5月6日 下午9:20
答复

Suresh Nimmakayala

等级: Liferay Master

帖子: 564

加入日期: 2004年8月17日

最近的帖子

Thanks David & Hitoshi,

That makes sense. created a EXT Plugin and in other portlet, liferay-plugin-package.properties add the ext-xxxx-ext-impljar to the poral dependency jars.

all good now i know some how it is simple emoticonemoticon

cheers
suresh
Suresh Nimmakayala
RE: can we import classes from one pluginsdk portlet to another ?
2012年5月7日 下午3:21
答复

Suresh Nimmakayala

等级: Liferay Master

帖子: 564

加入日期: 2004年8月17日

最近的帖子

David H Nebinger:
You cannot do this. They are separate war files and have separate class loaders.

Your only option is to create an EXT plugin. Code in the EXT plugin can be pulled into plugin projects the same way you can access portal jars.


now i have a doubt whatever i am moving portlets as plugins using sdk needs to used in other portlets am i going in the right way ?


previously i have done loads of portlets in extension environment.

i am moving portlets as plug-in portlets in 6.1ee


suppose i have portlet 1 ,portlet 2 , portlet 3, portlet 4 ,portlet 5 , portlet 6


portlet7 -- is suppose to be using all portlets displaying some of the methods of that above 6 portlets (like a report and links) in this case we can't use them unless they are ext-plugin emoticon


so those 6 portlets needs to be 6-extplugins ???????

Regards
Suresh
David H Nebinger
RE: can we import classes from one pluginsdk portlet to another ?
2012年5月7日 下午3:44
答复

David H Nebinger

等级: Liferay Legend

帖子: 7008

加入日期: 2006年9月1日

最近的帖子

Portlets should not be in the EXT plugin.

The EXT plugin should only contain your shared code.

Portlets (in most circumstances) should be in separate portlet plugins and use the liferay-plugin-package.properties file to reference the jars they have dependencies upon.
Hitoshi Ozawa
RE: can we import classes from one pluginsdk portlet to another ?
2012年5月7日 下午3:53
答复

Hitoshi Ozawa

等级: Liferay Legend

帖子: 7990

加入日期: 2010年3月23日

最近的帖子

As David replied, if you are writing your own portlets, you shouldn't be using ext plugin. ext plugins is only used to overwrite logics in liferay's source code.

If you have several portlets that are dependent on each other, why not just package them into one war file? Users would than only have to deploy one war file instead of several and you won't have to worry about portlet dependencies.
Hitoshi Ozawa
RE: can we import classes from one pluginsdk portlet to another ?
2012年5月6日 下午8:22
答复

Hitoshi Ozawa

等级: Liferay Legend

帖子: 7990

加入日期: 2010年3月23日

最近的帖子

Just copy move the generated jar file to the application server's lib directory (e.g. when using tomcat, it's liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23\lib\ext