Wednesday, 7 November 2012

Customizing Liferay Classes using ext plugin in 6.1

Liferay is highly flexible that developers can override any Liferay class by just replacing them in Ext Plugin. But overriding is not a very good action considering "Open for extension closed for Modification" Principle. 
so in this blog post I am going to show simple steps how to extend a Liferay class. 

Note: use ext plugin  class extension or replacement as a last resort if and only if the same cannot be achieved through hooks or other ways.

Step 1: Create you class by extending the Liferay class.
Step 2: Create a file called ext-spring in folder docroot/WEB-INF/ext-impl/src/META-INF
Step 3: From Liferay source code get the file portal-impl/src/META-INF/portal-spring.xml
Step 4: just copy the bean class you are extending from portal-spring.xml and paste to your ext-spring.xml, change the class name to your new extended class. (please ensure you have the <beans> outer tag too in ext-spring as in portal-spring)
step 5: deploy your ext, now Liferay will call your class instead of its own implementation.

0 comments:

Post a Comment