When I'm using below code getting warning that it's deprecated
renderRequest.getParameter("param")
Then I used
renderRequest.getRenderParameters().getValue("param")
as this was suggested by v3.0. But after that getting bellow error at run time
2020-11-19 02:58:02.537 ERROR [http-nio-8080-exec-6][render_portlet_jsp:131] null
java.lang.UnsupportedOperationException: Requires 3.0 opt-in
at com.liferay.portlet.internal.PortletRequestImpl.getRenderParameters(PortletRequestImpl.java:520)
at com.training.portlet.MyPortlet5.doView(MyPortlet5.java:61)
at com.liferay.portal.kernel.portlet.LiferayPortlet.doDispatch(LiferayPortlet.java:303)
at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.doDispatch(MVCPortlet.java:478)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:291)
at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.render(MVCPortlet.java:302)
at com.liferay.portlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:127)
at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:58)
at com.liferay.portlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:124)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:71)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:115)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153)
at org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest(ResponseStateHandler.java:62)
at org.eclipse.equinox.http.servlet.internal.context.DispatchTargets.doDispatch(DispatchTargets.java:120)
at org.eclipse.equinox.http.servlet.internal.servlet.RequestDispatcherAdaptor.include(RequestDispatcherAdaptor.java:48)
at com.liferay.portlet.internal.InvokerPortletImpl.invoke(InvokerPortletImpl.java:573)
at com.liferay.portlet.internal.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:670)
at com.liferay.portlet.internal.InvokerPortletImpl.render(InvokerPortletImpl.java:362)
at
This issue was because my portlet module was using portlet API v2.0 by default and getRenderParameters() is available since v3.0. So, when explicitly I mentioned in component class to use v3.0 and did Gradle refresh the issue got fix.
I could fix this issue by adding
"javax.portlet.version=3.0"
in portlet's component class.
@Component(
immediate = true,
property = {
"javax.portlet.version=3.0",
"com.liferay.portlet.display-category=category.app",
"com.liferay.portlet.instanceable=true",
"javax.portlet.init-param.template-path=/",
"javax.portlet.resource-bundle=content.Language",
"javax.portlet.security-role-ref=power-user,user",
"javax.portlet.init-param.view-template=/myportlet5/view.jsp",
"javax.portlet.name=" + MyModuleMainPortletKeys.MY_PORTLET5
},
service = Portlet.class