留言板

How to determine whether to use Hook or an EXT

Ria K,修改在7 年前。

How to determine whether to use Hook or an EXT

New Member 帖子: 6 加入日期: 16-5-17 最近的帖子
Hi,
I am very new to Liferay and trying to get the basic understanding of plugins and determine which plugin to use and when.
In regards to Hook and Ext, how is it determined which one to use:
1. Override a property file, I found definitions of properties here
(https://docs.liferay.com/portal/6.2/propertiesdoc/portal.properties.html), but how is it determined which property can be overridden by Hook and which one will need EXT
2. Is there a rule of thumb to determine when a JSP page can be overridden with Hook and what will need an EXT?
3. Does any core service that has service wrapper can be extended or overridden using Hook, else we need EXT

thanks in advance!!
thumbnail
Neil Griffin,修改在7 年前。

Moved to Liferay Portal - English - Development

Liferay Legend 帖子: 2655 加入日期: 05-7-27 最近的帖子
Moved to Liferay Portal - English - Development
thumbnail
Andrew Jardine,修改在7 年前。

RE: How to determine whether to use Hook or an EXT

Liferay Legend 帖子: 2416 加入日期: 10-12-22 最近的帖子
Hi Ria,

There is just one rule of thumb to follow.

IF you can do it with a HOOK, then ALWAYS choose a hook over an EXT.

EXT, at one point in time, was the only way to do anything in Liferay. Fortunately the product has evolved (tremendously) and given us not just "hooks" but all sorts of kinds of hooks that allow us to alter and or augment a lot... A LOT.. of the portal.

There are occasions where you get stuck with an EXT plugin. How do you determine when that is? Well, as I said, when you CAN'T use a hook -- which most of the time is when you want to alter something that is part of the portal-impl.jar.

As for you question about the services -- there is a service wrapper hook that you can write that will allow you to override existing services -- check tis out :: https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/overriding-a-portal-service-using-a-hook
Ria K,修改在7 年前。

RE: How to determine whether to use Hook or an EXT (答复)

New Member 帖子: 6 加入日期: 16-5-17 最近的帖子
Thanks Andrew!!

I am guessing the scenarios "when you CAN'T use a hook" is something you learn with experience and researching and there is not always straight answer to it even for portal properties override emoticon
thumbnail
Andrew Jardine,修改在7 年前。

RE: How to determine whether to use Hook or an EXT

Liferay Legend 帖子: 2416 加入日期: 10-12-22 最近的帖子
Experience is pretty much always everything. Best advice I can offer is to take advantage of the forums when you have questions. There is almost certainly someone else who has asked your question before. If they haven't, then ask away and almost certainly someone will answer with some best practices/guidance/examples.
thumbnail
David H Nebinger,修改在7 年前。

RE: How to determine whether to use Hook or an EXT

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
The only times I've ever had to fall back to an EXT was to replace or extend a class from portal-impl.jar. Most other use cases (struts override, service replacement, jsp override) can be handled by hooks.
Ria K,修改在7 年前。

RE: How to determine whether to use Hook or an EXT

New Member 帖子: 6 加入日期: 16-5-17 最近的帖子
Thanks Andrew and David,
I really appreciate you taking time to answer