Portal events or sometimes referred as action in Liferay are of different types.
They executes on different time and a developer can choose relevant action to perform.
You can find these entries in portal.properties-
1) Servlet service event
The pre-service events process before Struts processes the request.
The post-service events process after Struts processes the request.
servlet.service.events.pre
servlet.service.events.post
2) Login Events process after successful login only.
login.events.pre
login.events.post
3) Logout events called after successful logout.
logout.events.pre
logout.events.post
In this post we will be setting landing page in Liferay 7 OSGI way with post login action.
But at the end you will explore that all of the actions can be implemented by a single change of property.
I will be adding class only in the post, you can choose build type from - Gradle/Maven
To add events you need to -
1) Implement com.liferay.portal.kernel.events.LifecycleAction
2) Add annotation
@Component(
immediate = true, property = {"key=login.events.pre"},
service = LifecycleAction.class
)
that's all, you need to do :)
Below is the code you can refer -
package com.sample; import javax.servlet.http.HttpSession; import org.osgi.service.component.annotations.Component; import com.liferay.portal.kernel.events.ActionException; import com.liferay.portal.kernel.events.LifecycleAction; import com.liferay.portal.kernel.events.LifecycleEvent; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.struts.LastPath; import com.liferay.portal.kernel.util.StringPool; @Component( immediate = true, property = {"key=login.events.post"}, service = LifecycleAction.class ) public class LandingRedirectAction implements LifecycleAction { public static final Log LOGGER = LogFactoryUtil.getLog(LandingRedirectAction.class); @Override public void processLifecycleEvent(LifecycleEvent lifecycleEvent) throws ActionException { LOGGER.info("PostLogin called"); HttpSession session = lifecycleEvent.getRequest().getSession(); session.setAttribute("LAST_PATH", new LastPath(StringPool.BLANK, "/web/guest/landMeOnMoon")); } }
Now, in here if you want to change this action/event to be called on each page just change the property "key" to "servlet.service.events.pre" and add your code accordingly.
You are just done, Try & Enjoy the function.............:)
Share great information about your blog , Blog really helpful for us . We read your blog , share most useful information in blog . Thanks for share your blog here .
ReplyDeleteหนังสือ forex
ReplyDeleteHello, do you know how to stop the logout action in the pre logout event?
What I need is that I only continue if I send a parameter in the url, otherwise I redirect to the main page and continue with the session open.
Share great information about your blog , Blog really helpful for us
ReplyDeleteOn the off chance that you have to rent a bond blender and escavator, this will just increase your solid garage cost. Chape Braspenning: Chape voor Nieuwbouw of Renovatie
ReplyDeleteThe gathering could be recorded making minute taking simple. http://eddyleisure.com/stage-hire-yorkshire/
ReplyDeleteHow about we start our exchange about Christmas by taking a gander at the early Church as depicted in the New Testament. Brian May Net Worth
ReplyDeleteThis excellent website definitely has all of the information I needed concerning this subject and didn?t know who to ask.
ReplyDeleteghế gỗ giá rẻ
It’s hard to find experienced people in this particular topic, however, you seem like you know what you’re talking about! Thanks
ReplyDeleteXem thêm
Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. forro London
ReplyDeleteAs right on time as 3000 BC, the old Egyptians were the first to utilize the utilization of concrete in the structure of their pyramids.Chape
ReplyDeleteGreat job for publishing such a nice article. Your article isn’t only useful but it is additionally really informative. we provide stage hire melbourne at affordable prices. for more info visit our website.
ReplyDeleteGreat post, Which you have shared here. This information very important for every person those really interesting in Speaker Rental. We have a huge collection of sound instrument like D&B Audiotechnik. Visit our website for more updates!
ReplyDeleteThis time, do something truly thoughtful and add personalized birthday wishes and birthday poems to your card or gift. Your friends and family will know that you really spent some time and effort, and they will appreciate how much they were in your thoughts, as you have taken the time to add a personal touch to your birthday offering for them.
ReplyDeleteevent
Most importantly, the whole event left we all stunned. What we had thought to be an association in paradise, ended up being a shocking association, an association that was never intended to be. The far-fetched event of separation had never entered our thoughts.420 events nyc
ReplyDelete
ReplyDeleteReally nice and informative blog, keep it up. Thanks for sharing and I have some suggestions.
if you want to learn Mobile App Development(android, iOS), Join Now Mobile App Training in Bangalore.
Visit a Website:- Android Training in Bangalore | AchieversIT
This may help you to find something useful
Liên hệ Aivivu, đặt vé máy bay tham khảo
ReplyDeletevé máy bay đi Mỹ tháng nào rẻ nhất
chuyến bay đưa công dân về nước
ve may bay tư duc ve viet nam
dịch vụ vé máy bay tại nga
ve may bay tu anh ve viet nam
máy bay từ pháp về việt nam
danh sách khách sạn cách ly đà nẵng
. The specialists had disclosed to us that it was all around the second the growths were recognized in Jacques' mind. In case Jacques' days were numbered, mine had expected an example. music events
ReplyDeleteIt was an astonishing event. Mike was so amped up for it. He and Laura coordinated his 40th birthday celebration party with spirit and panache. web-based reserved seating software
ReplyDeleteIn case Jacques' days were numbered, mine had accepted an example. Each day I would go to office and each evening I would visit Jacques at the clinic before I got back.Learn about personal investments
ReplyDeleteI really like and appreciate your blog post. Much obliged.
ReplyDeleteget more details about event company
It is amazing and wonderful to visit your site. I've learned many things from your site.
ReplyDeletesquare truss rental orlando
We proceeded with our reality in this fantastic style for quite a while. My mom was occupied with her work; I was joyfully engaged with my inspirational, instructing and guiding meetings. Deep Etiching Service
ReplyDeleteThere was no change to or rest from this daily schedule. Its sheer dullness caused me to feel like a machine, as though I would go on with this drudgery even after Jacques' passing.events lineup
ReplyDeleteA home buying guide for first-time buyers with current information and calculators and every step of the buying process.Buying Your First Home in Canada
ReplyDeleteUse our Canadian Creditworthiness calculator to check your credit score and also get tips to boost your credit score. Buying Your First Home in Canada
ReplyDeleteExcellent blog!!! I really enjoy to read your post and thanks for sharing!
ReplyDeleteBest Divorce Lawyers in Arlington VA
Solicitation Of A Minor VA