Naresh Kallamadi
Naresh Kallamadi

Reputation: 163

Hit event on before every action in liferay means pre action event

I need to call the one method before action method calls in portlet controller.

So here I am using a hook like:

  1. Create Hook
  2. Create a class and extend Action.
  3. Override run method write my own logic.
  4. Create portal.properties file and added following line

servlet.service.events.pre=com.liferay.sample.hook.LoginAction

  1. Pointing it fron liferay-hook.xml

Every thing was went fine but here the problem with this one is the created hook is executed each and every time page load but I want execute this hook is only when I click on the Action buttons(Action urls) in any portlet.

Can any help me out on it?

Thanks in Advance.

Naresh Kallamadi

Upvotes: 0

Views: 1243

Answers (1)

VC1
VC1

Reputation: 1686

The property you are using relates to service actions, which are invoked before or after every Action. From my experience service actions happens every time a page loads. This would explain the behavior you are seeing.

For more in-depth understanding, the article Overriding Events and working with preactions and postactions in EXT will help.

I think you may want to dig more into the portlet actions and phases to achieve what you may need. Please post back if you have more details (code example of what you have tried etc.) on the exact behavior in the portlet you need help with.

Hope this helps.

Upvotes: 0

Related Questions