Fórumok

How to Create Model Listener Class in Plugin?

thumbnail
Faisal K, módosítva 14 év-val korábban

How to Create Model Listener Class in Plugin?

Regular Member Bejegyzések: 138 Csatlakozás dátuma: 2008.01.09. Legújabb bejegyzések
Hi All,


I want to create a Model listener class for one of my service entities created under plugin environement,If any body have done this before, please help me how to do this?

One more thing I am seeing there are some extra classes like 'CLPMessageListener' is created only for plugin environement, what are these classes all about?

Thanks In advance.
thumbnail
Wilson Man, módosítva 14 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Liferay Master Bejegyzések: 581 Csatlakozás dátuma: 2006.06.21. Legújabb bejegyzések
http://www.liferay.com/web/guest/community/forums/-/message_boards/message/2648040

as for the CLP stuff, i believe those are for hot deployment ...
thumbnail
Faisal K, módosítva 14 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Regular Member Bejegyzések: 138 Csatlakozás dátuma: 2008.01.09. Legújabb bejegyzések
Thanks for the reply Wilson,

Actually I want to write a Listener class for one of my Service Entity, means when I am creating or updating that entity I want to do some action like sending a mail, etc. I think it can be doable using ModelListener but I have to mention it in

value.object.listener.${model.class.} in portal-ext.properties this is for EXT environment (User,Message Board listeners are working fine), now I am trying to do the same in plugin environment using portlet.properties, but not working, is there any other way like hook. Earlier in the Hook there was a tag to mention the Events(model-listener exists in 5.0 dtd) but not exists in 5.2.0 dtd., Can you help me what is the other solution for doing this?
thumbnail
Wilson Man, módosítva 14 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Liferay Master Bejegyzések: 581 Csatlakozás dátuma: 2006.06.21. Legújabb bejegyzések
oh right, i misread your post. Yeah, what you want to do is this ...

1. in your entity's PersistenceImpl class, do a search for the string "value.object". You'll find something like this:
value.object.listener.com.<the_rest_of_your_class_path></the_rest_of_your_class_path>

2. copy and paste that into docroot/WEB-INF/src/service.properties and set that = to your custom model listener
3. (i guess this should be step 1 really) create your custom listener and extend the BaseModelListener class


One thing to note though, due to some constraints in easyconf, service-ext.properties doesn't work as it should. So you need to put this property in your service.properties file. And re-add it back each time you rebuild your services cuz ant build-service will remove your entries.
thumbnail
Faisal K, módosítva 14 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Regular Member Bejegyzések: 138 Csatlakozás dátuma: 2008.01.09. Legújabb bejegyzések
Hi,

Thanks for your Reply, I will try this.
thumbnail
Stef Heyenrath, módosítva 14 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Junior Member Bejegyzések: 76 Csatlakozás dátuma: 2008.12.03. Legújabb bejegyzések
Wilson Man:

One thing to note though, due to some constraints in easyconf, service-ext.properties doesn't work as it should. So you need to put this property in your service.properties file. And re-add it back each time you rebuild your services cuz ant build-service will remove your entries.


I fixed this by overriding the build-service target in the build.xml from the portlet:
<target name="build-service" depends="clean">
	<ant antfile="../build-common-portlet.xml" target="build-service" />

	<concat destfile="${src}/service.properties" append="true" fixlastline="yes" eol="crlf">
		<filelist dir="${src}" files="service-ext.properties" />
	</concat>
</target>


Because I use concat, I need some more CRLF's at the top of the service-ext.properties :



# Do not remove CRLFs at the top of this file !!!

# Listeners
value.object.listener.com.test.model.MyEntity=com.test.services.listeners.MyEntity


I hope this helps.
thumbnail
charles de courval, módosítva 13 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Junior Member Bejegyzések: 55 Csatlakozás dátuma: 2010.07.31. Legújabb bejegyzések
Hi Wilson,
I tried your solution, and I have the following problem:
Loading file:/C:/projects/ACQ/trunk/programs/liferay-portal-6.0.5/tomcat-6.0.26/webapps/ACQ-portlet/WEB-INF/classes/service.properties
16:15:19,090 ERROR [EnterprisePersistenceImpl:2452] 
java.lang.ClassNotFoundException: com.acq.portlet.enterprise.model.impl.EnterpriseListener
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
.......


The configuration in service.properties is as follows:
value.object.listener.com.acq.portlet.enterprise.model.Enterprise = com.acq.portlet.enterprise.model.impl.EnterpriseListener

but for some reason the class is never found by the class loader.

The class does exists in my package emoticon

Any idea ?
thumbnail
Paul ., módosítva 12 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Liferay Master Bejegyzések: 522 Csatlakozás dátuma: 2011.08.29. Legújabb bejegyzések
but for some reason the class is never found by the class loader.

Having the same problem , has anyone found a solution yet?
thumbnail
Paul ., módosítva 12 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Liferay Master Bejegyzések: 522 Csatlakozás dátuma: 2011.08.29. Legújabb bejegyzések
After some searching , there is a workaround on http://issues.liferay.com/browse/LPS-10988
thumbnail
Ivano Carrara, módosítva 12 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Expert Bejegyzések: 345 Csatlakozás dátuma: 2005.07.03. Legújabb bejegyzések
Hi all,

I installed it in Liferay SDK the new buil-common-plugin.xml from the LPS-10988 workaround, then I replaced the name of my service package as below:

<replace dir="${basedir}/docroot/WEB-INF/src/o2/base/service/persistence" includes="*PersistenceImpl.java" summary="yes"></replace>


... and rebuilt the services but the error is still the same:

Caused by: com.liferay.portal.kernel.bean.BeanLocatorException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'o2.base.service.persistence.OMUserDittaPersistence' is defined


Anyone used the modified build-common-plugin.xml as the workaround from http://issues.liferay.com/browse/LPS-10988 ?

Thank you in advance!

Ivano C.
thumbnail
Ivano Carrara, módosítva 12 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Expert Bejegyzések: 345 Csatlakozás dátuma: 2005.07.03. Legújabb bejegyzések
After reading the entire post and installed in Liferay SDK the new buil-common-plugin.xml from the LPS-10988 workaround, I wrote in the service.properties file the below property:

value.object.listener.o2.base.model.OMUserDitta=o2.base.listener.UserDittaListener


but during the Tomcat start up still I get the below error:

Loading file:/C:/dev/liferay/bundles/liferay-portal-tomcat-6.0.6/tomcat-6.0.29/webapps/o2-base-portlet/WEB-INF/classes/service.properties
17:40:01,300 ERROR [OMUserDittaPersistenceImpl:6986]
java.lang.ClassNotFoundException: o2.base.listener.UserDittaListener


The names and paths are ok but it can't find my model listener class....

Please, someone can help me?

Thank you!
Ivano C.
thumbnail
Ivano Carrara, módosítva 12 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Expert Bejegyzések: 345 Csatlakozás dátuma: 2005.07.03. Legújabb bejegyzések
Hi Charles, maibe you solved the java.lang.ClassNotFoundException error ?

Thank you for some help...

Ivano C.
Kirk Stork, módosítva 11 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Junior Member Bejegyzések: 33 Csatlakozás dátuma: 2010.05.19. Legújabb bejegyzések
Wilson Man:
oh right, i misread your post. Yeah, what you want to do is this ...

1. in your entity's PersistenceImpl class, do a search for the string "value.object". You'll find something like this:
value.object.listener.com.<the_rest_of_your_class_path></the_rest_of_your_class_path>

2. copy and paste that into docroot/WEB-INF/src/service.properties and set that = to your custom model listener
3. (i guess this should be step 1 really) create your custom listener and extend the BaseModelListener class


One thing to note though, due to some constraints in easyconf, service-ext.properties doesn't work as it should. So you need to put this property in your service.properties file. And re-add it back each time you rebuild your services cuz ant build-service will remove your entries.



Isn't there a safe place/way to simply call registerListener() from your plugin's code?
ronak vora, módosítva 3 év-val korábban

RE: How to Create Model Listener Class in Plugin?

Junior Member Bejegyzések: 25 Csatlakozás dátuma: 2018.09.26. Legújabb bejegyzések
Hello Wilson Man,
       There is into service.properties file entry deleted automatically can we have any solution.
and i've make entry into hook > portal.properties 
value.object.listener.org.food.model.FoodModel=com.food.listeners.Foodistener

does anything else require to add CustomModelListener(FoodModelListener)?