Liferay DXP Modal Listener Hook


Liferay DXP Modal Listener Hook

Liferay DXP Modal Listener Hook tutorial is to customize liferay dxp modal listeners in Liferay DXP or Liferay 7

Installations:

Liferay DXP Modal Listener Customization:

    • Create Component Class in the Module Project:┬áCustomUserModalLister.java
    • Modal listeners actions the @Component annotation configuraion is:
      • Class need to extend BaseModalListener<T>
      • @Component Configuration is:
      • @Component(
         immediate = true,
         service = ModelListener.class
        )
    • CustomUserModalLister.java class is:
      1. package org.demo.liferay.listeners.portlet;
        
        import com.liferay.portal.kernel.exception.ModelListenerException;
        import com.liferay.portal.kernel.log.Log;
        import com.liferay.portal.kernel.log.LogFactoryUtil;
        import com.liferay.portal.kernel.model.BaseModel;
        import com.liferay.portal.kernel.model.BaseModelListener;
        import com.liferay.portal.kernel.model.ModelListener;
        import com.liferay.portal.kernel.model.User;
        import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet;
        
        import javax.portlet.Portlet;
        
        import org.osgi.service.component.annotations.Component;
        
        @Component(
         immediate = true,
         service = ModelListener.class
        )
        public class CustomUserModalLister extends BaseModelListener<User> {
         
         
         @Override
         public void onAfterUpdate(User model) throws ModelListenerException {
         _log.info("user is updateing");
         super.onAfterUpdate(model);
         }
         
         private static final Log _log = LogFactoryUtil.getLog(CustomUserModalLister.class);
        }
    • Now deploy the bundle and can see the bundle started message in the logs

Edit the User Info on My Account page and you can see the message on console.

Leave a Reply

Your email address will not be published. Required fields are marked *