Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Smilelws2010 lwz
Custom directory portlet based on Liferay Out of the box portlet
August 31, 2012 7:12 AM
Answer

Smilelws2010 lwz

Rank: Regular Member

Posts: 153

Join Date: December 16, 2010

Recent Posts

HI,

Could anyone tell how to create a custom portlet based on the liferay source code.

I would like to create separate directory portlet as we have a need to have two different portlets. How does the directory structure go and all.

I tried basically copying all the jsp files and a particular class com.liferay.portlet.usersadmin.action.EditUserAction under docroot of a newly created portlet, but when run I got lot of errors in the java class related to import statements etc. Basically it is not able to find other classes which are mentioned. I blindly tried to copy portal-impl.jar to liferay-plugin-package.properties. But while deploying using ant it said

"Detected inclusion of portal-impl.jar in WEB-INF/lib.

portal-impl.jar is designed with a large number of singleton classes which are
instantiated on the basis that they will exist alone in the application server.

While compile time issues may be resolved, portlets cannot be made to work by
simply adding portal-impl.jar, because doing so violates the above assumption,
and the resulting problems will be extremely difficult to debug.

Please find a solution that does not require portal-impl.jar.

"

Please help me or redirect me if this is entirely wrong route. I have seen lot of people in the forum has created cutom portlets.

Thanks
SMile
Ray Augé
RE: Custom directory portlet based on Liferay Out of the box portlet
August 31, 2012 7:46 AM
Answer

Ray Augé

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1238

Join Date: February 7, 2005

Recent Posts

Yeah, don't approach it that way.

So, there are two ways to do it.

1) a hook plugin (this is what most people do)
2) a completely new portlet which just borrows the ideas of the original (this is what really ambitions people do)

--

1) is easy because you can change the JSPs simple or complex changes, one downfall however, is that it affects the core portlet directly and so you no longer have the original portlet. However this could be effectively managed by making changes that only come into effect with some portlet preference or run time rule, however you define that.

2) obviously this gives you ultimate flexibility while also preserving the original. However, it requires far more work.

So, the question really boils down to "How custom is custom?" What exactly is it that you need to be customized?
Smilelws2010 lwz
RE: Custom directory portlet based on Liferay Out of the box portlet
August 31, 2012 7:50 AM
Answer

Smilelws2010 lwz

Rank: Regular Member

Posts: 153

Join Date: December 16, 2010

Recent Posts

HI Ray,

Thanks for the quick reply and taking a look into this.

I have gone the hook way and it works really well. But a scenario arised you need to give view permission to guests as well. Which I could do using the same hook by modifying few jsps and some conditions, but had to do some changes in configuration files in portal-impl.jar file to achieve this.

Hence all the upper management perfer to have a second direcotry portlet more or less similar to liferay, andI would also get to learn more on creating completely custom portlet.

Could you help me or rather guide me in how to achieve this.

Thanks