Fórum

Import custom class from document library

Pierre-Olivier Kaplan, modificado 9 Anos atrás.

Import custom class from document library

New Member Postagens: 10 Data de Entrada: 06/10/14 Postagens Recentes
Hello,


Before posting, I saw that many peoples faced the same kind of problem than me, but I couldn't find a simple solution.

I'm developping a system which sends email notifications when a file from the document library is created/updated/deleted : each user with the view right receives an email.

Therefore, I released all the mailing and Notifications algorithms directly in <myProject>/docroot/WEB-INF/src/com/<myProject>/portal/common/NotificationUtil.java
It's located there because it needs others classes and models which are parts of the portlets project. And moreover, some portlets' classes are using this util too.

And there is the problem : I created a hook, in order to call this util from the document library jsp. But obviously, one can not simply import the NotificationUtil in the hook file.

So the questions are : Is there a way to import it in the hook ? Or should I look for another way ?

Thanks by advance,


Pierre-Olivier
thumbnail
Andew Jardine, modificado 9 Anos atrás.

RE: Import custom class from document library

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hi Pierre,

In this case I think I would leverage the messaging features that come with Liferay. This will allow you to register a destination as part of your portlet and then in the JSP you simply create a message and route it to the destination -- leaving Liferays core api to do the donkey work for you. Have a look at this --

https://www.liferay.com/documentation/liferay-portal/6.2/development/-/ai/using-message-bus-liferay-portal-6-2-dev-guide-06--1

.. also, you might consider a StrutsActionHook instead of a JSP considering that this is more presentation than it is logic. Overriding the struts action would also let you handle not just sucesses but also failures etc. if need be.
thumbnail
Jitendra Rajput, modificado 9 Anos atrás.

RE: Import custom class from document library

Liferay Master Postagens: 875 Data de Entrada: 07/01/11 Postagens Recentes
See if following blog can help you ..

https://www.liferay.com/web/kzhang/blog/-/blogs/using-custom-java-classes-in-a-jsp-hook

You can create model listener for document library and on creation/updation/deletion you can trigger emails.

Thank you,
Jitendra
thumbnail
Andew Jardine, modificado 9 Anos atrás.

RE: Import custom class from document library

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Oh -- that is a much better idea. I would definitely go with Jitendras suggestion first emoticon. Completely forgot about model listeners.