Reputation: 33
My requirement is that I need to store user-cart object in portlet session. Whenever user adds the item into cart the user-cart object should be updated and again saved into portlet session. Whenever the user logouts /session expires these user-cart object details should be saved into database. I am able to save the object in portlet session but when the user logouts /session expires the details are not getting saved into database. I override the "LogoutPreAction" class using Hook. But in run method I am unable to get the PortletSession object. How to get the portlet session object in run method of "MyCustomLogoutPreAction" class?
Upvotes: 0
Views: 711
Reputation: 48057
If your business data must survive the life of a UI-layer session, it might be best to totally decouple them from a front end session. After all, it's not guaranteed that a session destroy event is ever called (e.g. on appserver shutdown or even crash). Thus it might be advisable to update the database on every change to the shopping cart and just key that DB-data with the user's identifier.
This neatly keeps your business layer clean and independent of the actual frontend. Plus you're not depending on events that aren't guaranteed to be triggered ever.
Upvotes: 0
Reputation: 36
Try Servlet session destroy event. @see "servlet.session.destroy.events" property in portal.properties
#
# Servlet session destroy event
#
servlet.session.destroy.events=
Upvotes: 0