Liferay provides us facility to
execute some code before and after of some specific events, namely Login, Logout
and Service. Login and Logout are self-explanatory, Service is the event that
takes place before or after every Action. For instance, If we have
CustomServicePreAction and CustomLOginPreAction, in that case CustomServicePreAction
will be called first then CustomLOginPreAction and then the LoginAction class
will be invoked.
To achieve this, we need to make some
entry in the portal-ext.properties, however some values are already present in
portal.properties file, we have to update those properties, as following:
Here the our custom classes are:
Now we have to add the following classes in Ext:
1. CustomServicePreAction
2. CustomServicePostAction
3. CustomLoginPreAction
4. CustomLoginPostAction
5. CustomLogoutPreAction
6. CustomLogoutPostAction
Here the our custom classes are:
- com.liferay.portal.events.CustomServicePreAction,
- com.liferay.portal.events.CustomServicePostAction,
- com.liferay.portal.events.CustomLoginPreAction,
- com.liferay.portal.events.CustomLoginPostAction,
- com.liferay.portal.events.CustomLogoutPreAction, and
- com.liferay.portal.events.CustomLogoutPostAction.
Now we have to add the following classes in Ext:
1. CustomServicePreAction
2. CustomServicePostAction
3. CustomLoginPreAction
4. CustomLoginPostAction
5. CustomLogoutPreAction
6. CustomLogoutPostAction
And now, run your code. It will
work.
Hi
ReplyDeletewe can implement CustomLoginPreAction,CustomLoginPostAction,CustomLogoutPostAction and CustomLogoutPreAction using hook.so why we need to go for EXT.correct me if i'm wrong
Yes you are correct, but this article especially deals with EXT approach. I'm in-progress of writing an article with hooks approach too. thanks for asking.
DeleteThanks for your blog it's really helpful, I have one doubt that what is the exact difference in post and pre login and logout event. I have some confusion, if we check for a user is login or not then any of then can be used, may be possibility some seconds of difference. Then why these two. Thanks
ReplyDelete