JSP Override with OSGi Fragments
JSP Override with OSGi Fragments
Note: article is obsolete, check new version here.
Overview
This article describes how to create custom JSP Override module (AKA JSP Hook in previous Liferay versions).
Note: Although this way is not recommended way by Liferay (see: https://portal.liferay.dev/docs/7-2/customization/-/knowledge_base/c/jsp-overrides-using-osgi-fragments), it seems to be the most straightforward and powerfult approach.
JSP-Override module creation
1 - Finding the required JSP in Liferay sources.
Let's say, for example, you need to customize Asset Publisher configuration and add additional option for Content Set Provider configuration: max items count to display.
Find the appropriate JSP file in Liferay sources: for Liferay 7.2 CE GA 1 this is:
liferay-ce-portal-src-7.2.0-ga1-20190531153709761.zip!/liferay-ce-portal-src-7.2.0-ga1/modules/apps/asset/asset-publisher-web/src/main/resources/META-INF/resources/configuration/asset_list_provider.jsp
liferay-ce-portal-src-7.2.0-ga1-20190531153709761.zip!/liferay-ce-portal-src-7.2.0-ga1/modules/apps/asset/asset-publisher-web/src/main/resources/META-INF/resources/configuration/asset_list_provider.jsp
2 - Finding the required JSP in Marketplace LPKG file.
We found, that required JSP in under asset-publisher-web
folder in Liferay sources.
Thus, find appropriate *.lpkg file in LR/osgi/marketplace
folder.
For our case it's Liferay CE Web Experience - Liferay CE Asset - Impl.lpkg
. Copy it somewhere and unpack.
Find the same JSP in the appropriate JAR file
asset-publisher-web
folder in Liferay sources.LR/osgi/marketplace
folder.Liferay CE Web Experience - Liferay CE Asset - Impl.lpkg
. Copy it somewhere and unpack.3 - Create module for JSP Override
Create module in your Liferay workspace.
Configure the bnd.bnd
file:
Bundle-Name: Asset Publisher Configuration JSP Override
Bundle-SymbolicName: com.lifedev.asset.publisher.configuration.jsp.override
Bundle-Version: 1.0.0
Fragment-Host: com.liferay.asset.publisher.web;bundle-version="3.0.21"
-sources: true
Fragment-Host should point to module found above: in this example for com.liferay.asset.publisher.web-3.0.21.jar
Fragment-Host value is: com.liferay.asset.publisher.web;bundle-version="3.0.21"
Copy JSP to your module (using the same folder, META-INF/resources/configuration
here).
Add required customization, for example
bnd.bnd
file:Bundle-Name: Asset Publisher Configuration JSP Override
Bundle-SymbolicName: com.lifedev.asset.publisher.configuration.jsp.override
Bundle-Version: 1.0.0
Fragment-Host: com.liferay.asset.publisher.web;bundle-version="3.0.21"
-sources: true
com.liferay.asset.publisher.web-3.0.21.jar
Fragment-Host value is: com.liferay.asset.publisher.web;bundle-version="3.0.21"
META-INF/resources/configuration
here).4 - Deploy module
Deploy module with JSP Override.
Note: after successful deployment module state will be Resolved
, not Active.
Verify, if changed applied.
Congratulations! You have implemented the JSP Override 👌
But it's too early to drink beer 🍺
You still need to save the added field on customized JSP on the backend. For this you may use the Porltet Filter.
Enjoy 😏
Resolved
, not Active.
Comments
Post a Comment