Fórum

Liferay Hook overriding JSP's and properties

Suman A, modificado 7 Anos atrás.

Liferay Hook overriding JSP's and properties

New Member Postagens: 9 Data de Entrada: 30/07/15 Postagens Recentes
Hi All,

As I am new to the liferay , And I have come across the cool feature in Liferay which is "hook" plugin . And I would like to know how does it works internally.

1- As I have override one of the liferay portal JSP using hook , It works as expected but can any one let me know how liferay consider my JSP and why Liferay is not taking Actual JSP.

I have a scenario like
I have deployed a hook by overriding a JSP , then
I have deployed a liferay patch which is having one of the JSP

In this case which JSP will comes in to picture either hook one or patch or actual JSP ? And how?

2- Also i have override a liferay one of the property using hook also i have changed the same property value via Control Panel
Here my question how liferay prefer these properties , which is more property here either from Control panel or portal-ext.properties or hook ?
And why so?

Thanks & Regards,
Suman A.
thumbnail
Andrew Jardine, modificado 7 Anos atrás.

RE: Liferay Hook overriding JSP's and properties

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hi Suman,

I'll give this a shot, assuming I understand your question.

For #1 ...
For JSP hooks what happens is this. You create the plugin and then deploy it. Let's say you override an existing JSP that the portal provides (you don't have to, you can also use a hook to introduce new JSPs that you want to reference). The portal will see that the file exists already so what it will do is change the name of the EXISTING file to contain .portal in the name. It will then copy the file you provide into the location. So let's say you hook the /html/portal/login/login.jsp -- all the references to this file will now be to yours. When you undeploy your hook, the file that was placed during the override (the one in your hook) is removed and the .portal version is renamed back to the original name.

For #2 ...
The principal way to override properties is done using the portal-ext file, or a derivative of it that you may use. The second way, is using the control panel. The control panel option contains only SOME of the settings that are in the full .properties file though. There are two util classes that are typically used to read properties. PropsUtil, or PrefsPropsUtil. The difference, if you look at the source, is that the PrefsPropsUtil will consider entries that are found in the PortalPreferences table (items from the control panel) -- and if it finds it in that table, then it will return that value. if the item is not in that table, it will fall back to the properties from the file. So the rule of thumb is, anything that you set in the control panel will take precedence over its equivalent in the portal.properties. If you right click on a field in the control panel you will see that part of the element name looks like a property (eg. _130_default.landing.page.path) -- the first part is the namespace for the portlet, the second is the property that you are setting. You will also find this property in the portal.properties file for the portal with some default value.

Does that answer your question?