Foros de discusión

Extending of Portlets (OSGI) in Liferay 7

Jack Thinkin, modificado hace 7 años.

Extending of Portlets (OSGI) in Liferay 7

Junior Member Mensajes: 45 Fecha de incorporación: 9/05/16 Mensajes recientes
Hello,
is it possible to extend existing portlets (JSP and Java Classes) that are implemented as OSGI modules in Liferay 7?
(for example Asset Portlet)
Thanks
thumbnail
Ray Augé, modificado hace 7 años.

RE: Extending of Portlets (OSGI) in Liferay 7

Liferay Legend Mensajes: 1197 Fecha de incorporación: 8/02/05 Mensajes recientes
[update] I read too quickly.
You can only extend classes which are part of the portlet bundle's exported API, which is not typical for portlets.

Overriding JSPs is handled through fragments. This is documented in the developer guide here.

However, I would suggest integrating with existing portlets through clean APIs such as the example below demonstrates.

[original below]
Yup! emoticon

Portlet support in Liferay 7.0 has been enhanced such that any of the portlet related integration points can be provided as plain OSGi services, the key piece of information is typically the service property `javax.portlet.name`. This is what binds the service to the portlet. There are too many integration points to list here, but effectively looking at the types supported by the old `liferay-portlet.xml` are supported by this mechanism, plus several more.

For instance, if you wish to attach a `javax.portlet.filter.RenderFilter` to an existing portlet who's `javax.portlet.name` is `foo` you would do (I'm using DS since that's the preferred way to work in OSGi):

@Component(
	property = {
		"javax.portlet.name=foo"
	}
)
public class FooRenderFilter implements RenderFilter {
	public void destroy() {
		// TODO Auto-generated method stub
	}
	public void init(FilterConfig config) throws PortletException {
		// TODO Auto-generated method stub
	}
	@Override
	public void doFilter(
			RenderRequest request, RenderResponse response, FilterChain chain)
		throws IOException, PortletException {
		// TODO Auto-generated method stub
	}
}


and that's it!
Jack Thinkin, modificado hace 7 años.

RE: Extending of Portlets (OSGI) in Liferay 7

Junior Member Mensajes: 45 Fecha de incorporación: 9/05/16 Mensajes recientes
thanks
i have tried blade example with overwriting of login.jsp, but i don't have any result in trial of overwriting of asset publisher jsp.
Is it correct content of file bnd.bnd for asset publisher?

Bundle-Version: 1.0.0
Fragment-Host:com.liferay.asset.publisher.web;bundle-version="1.0.6"
-sources: true
-jsp: *.jsp,*.jspf
-plugin.jsp: com.liferay.ant.bnd.jsp.JspAnalyzerPlugin
thumbnail
Ray Augé, modificado hace 7 años.

RE: Extending of Portlets (OSGI) in Liferay 7

Liferay Legend Mensajes: 1197 Fecha de incorporación: 8/02/05 Mensajes recientes
Note there was a compiled JSP caching bug which prevented the jsp fragments from affecting any change:

https://issues.liferay.com/browse/LPS-65034
thumbnail
Ray Augé, modificado hace 7 años.

RE: Extending of Portlets (OSGI) in Liferay 7

Liferay Legend Mensajes: 1197 Fecha de incorporación: 8/02/05 Mensajes recientes
also, after a brief glance your bnd looks fine.