留言板

can we import classes from one pluginsdk portlet to another ?

thumbnail
Suresh Nimmakayala,修改在11 年前。

can we import classes from one pluginsdk portlet to another ?

Liferay Master 帖子: 690 加入日期: 04-8-18 最近的帖子
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
thumbnail
David H Nebinger,修改在11 年前。

RE: can we import classes from one pluginsdk portlet to another ?

Liferay Legend 帖子: 14915 加入日期: 06-9-2 最近的帖子
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.
thumbnail
Suresh Nimmakayala,修改在11 年前。

RE: can we import classes from one pluginsdk portlet to another ?

Liferay Master 帖子: 690 加入日期: 04-8-18 最近的帖子
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
thumbnail
Suresh Nimmakayala,修改在11 年前。

RE: can we import classes from one pluginsdk portlet to another ?

Liferay Master 帖子: 690 加入日期: 04-8-18 最近的帖子
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
thumbnail
David H Nebinger,修改在11 年前。

RE: can we import classes from one pluginsdk portlet to another ?

Liferay Legend 帖子: 14915 加入日期: 06-9-2 最近的帖子
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.
thumbnail
Hitoshi Ozawa,修改在11 年前。

RE: can we import classes from one pluginsdk portlet to another ?

Liferay Legend 帖子: 7942 加入日期: 10-3-24 最近的帖子
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.
thumbnail
Hitoshi Ozawa,修改在11 年前。

RE: can we import classes from one pluginsdk portlet to another ?

Liferay Legend 帖子: 7942 加入日期: 10-3-24 最近的帖子
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