RE: setRenderParameter is deprecated

thumbnail
Roman Novikov, modified 7 Years ago. Junior Member Posts: 39 Join Date: 1/7/17 Recent Posts

Hi, colleagues!

Moving  6.2 version code to  7.1 module I see strikeout function actionResponse.setRenderParameter  (deprecated).

What is the right way to pass parameters to a portlet request?

thumbnail
Minhchau Dang, modified 7 Years ago. Liferay Master Posts: 598 Join Date: 10/22/07 Recent Posts
Roman Novikov:

Hi, colleagues!

Moving  6.2 version code to  7.1 module I see strikeout function actionResponse.setRenderParameter  (deprecated).

What is the right way to pass parameters to a portlet request?

According to the StateAwareResponse.setRenderParameter deprecation note, the expectation is that you call actionResponse.getRenderParameters().setValue(...) instead.

thumbnail
Roman Novikov, modified 7 Years ago. Junior Member Posts: 39 Join Date: 1/7/17 Recent Posts

Thank you Minhchau for your answer!

I tried to correct my code this way. But is seems to impossible to get the parameters with PortalUtil.get..(request, <parameter>) after these changes...

thumbnail
Roman Novikov, modified 7 Years ago. Junior Member Posts: 39 Join Date: 1/7/17 Recent Posts
Minhchau Dang:

According to the StateAwareResponse.setRenderParameter deprecation note, the expectation is that you call actionResponse.getRenderParameters().setValue(...) instead.

So I still can not replace actionResponse.setRenderParameter ()   with  actionResponse.getRenderParameters().setValue  because the functions PortalUtil.get... return nothing after. I considered to investigate: how the Liferay developers deal with it. And this is a result:

techusr@UHOST01:~/Laboratory/Java/Liferay/liferay-ce-portal-src-7.1.0-ga1$ grep -rnw . -e "getRenderParameters"
./modules/apps/alloy/alloy-mvc/src/main/java/com/liferay/alloy/mvc/internal/json/web/service/AlloyMockUtil.java:152:        public RenderParameters getRenderParameters() {
./modules/apps/alloy/alloy-mvc/src/main/java/com/liferay/alloy/mvc/internal/json/web/service/AlloyMockUtil.java:204:        public MutableRenderParameters getRenderParameters() {
./modules/apps/alloy/alloy-mvc/src/main/java/com/liferay/alloy/mvc/internal/json/web/service/AlloyMockUtil.java:1197:        public RenderParameters getRenderParameters() {
./modules/apps/portal-search/portal-search-web/src/main/java/com/liferay/portal/search/web/internal/portlet/shared/search/NullPortletURL.java:63:    public MutableRenderParameters getRenderParameters() {
./modules/apps/opensocial/opensocial-portlet/docroot/WEB-INF/src/com/liferay/opensocial/editor/portlet/EditorPortlet.java:97:            else if (resourceID.equals("getRenderParameters")) {
./modules/apps/opensocial/opensocial-portlet/docroot/editor/js/main.js:1488:                            'getRenderParameters',
./portal-impl/src/com/liferay/portlet/internal/PortletURLImpl.java:298:    public MutableRenderParameters getRenderParameters() {
./portal-impl/src/com/liferay/portlet/internal/PortletRequestImpl.java:486:    public RenderParameters getRenderParameters() {
./portal-impl/src/com/liferay/portlet/internal/StateAwareResponseImpl.java:93:    public MutableRenderParameters getRenderParameters() {
./portal-impl/src/META-INF/javadocs-all.xml:160480:            <name>getRenderParameters</name>
./portal-impl/src/META-INF/javadocs-all.xml:682027:            <name>getRenderParameters</name>
./portal-impl/test/integration/com/liferay/portal/kernel/portlet/bridges/mvc/MVCActionCommandTest.java:292:        public RenderParameters getRenderParameters() {
./util-taglib/src/com/liferay/taglib/portlet/DefineObjectsTag3.java:128:                stateAwareResponse.getRenderParameters());
./portal-kernel/src/com/liferay/portal/kernel/portlet/DummyPortletURL.java:70:    public MutableRenderParameters getRenderParameters() {
./portal-kernel/src/com/liferay/portal/kernel/portlet/PortletURLWrapper.java:71:    public MutableRenderParameters getRenderParameters() {
./portal-kernel/src/com/liferay/portal/kernel/portlet/PortletURLWrapper.java:72:        return _portletURL.getRenderParameters();

This shows that Liferay developers still use the deprecated actionResponse.setRenderParameter ()   method.

Should this be an instruction for us to use the deprecated method and not mind the "struck-out" methods?

 

 

 

 

thumbnail
Minhchau Dang, modified 7 Years ago. Liferay Master Posts: 598 Join Date: 10/22/07 Recent Posts
Roman Novikov:

This shows that Liferay developers still use the deprecated actionResponse.setRenderParameter ()   method.

Should this be an instruction for us to use the deprecated method and not mind the "struck-out" methods?

No, I'd classify it as a hint that Liferay isn't finished with Portlet 3 yet.

If you've found that the deprecated method still works, but the correct way does not work yet, it's fine to continue using it, knowing that it carries the risk of relying on deprecated functionality. More specifically, because Liferay is still in the middle of implementing support for Portlet 3, your customizations might suddenly stop working once Liferay finishes its Portlet 3 implementation.

I don't think it's likely, but if you see a mass replace where all of the code in 7.1.x is switched to use the Portlet 3 pattern, followed by an update to the Breaking Changes document, be prepared to do a mass replace in your own code.

thumbnail
Olaf Kock, modified 7 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Minhchau Dang:
 More specifically, because Liferay is still in the middle of implementing support for Portlet 3, your customizations might suddenly stop working once Liferay finishes its Portlet 3 implementation.

I hope that nobody understands "deprecated" as "discontinued" when implementing the Portlet 3 spec. This is supposed to be backwards compatible, and only when removed, not when deprecated, should the old way stop to work.  E.g., I'd expect to see the deprecated way to work for the foreseeable future, as long as Portlet 3 is implemented.

If it won't, please register my disapproval and complaint in advance. :)

 

 

thumbnail
Neil Griffin, modified 7 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts

Liferay Portal 7.1.0 GA1 was built against portlet-api-3.0.0.jar but as Minhchau indicated, full implementation of Portlet 3.0 will not be available until 7.1.1 GA2 is released.

For detailed changes, you can refer to the recently published Portlet 3.0 API Javadoc. Be sure to click on the "Switch to Color-Coded Version" link to see all the fine distinctions with what has changed.

Aside from the edge-cases listed in the Breaking Changes document, Portlet 3.0 is binary-backward-compatible with Portlet 2.0. The deprecated methods will continue to function in the future. I represented Liferay on the Portlet 3.0 Expert Group and there was no talk of pruning or disabling any deprecated features in the future.

Note that usage of the new API methods will require the developer to opt-in to Portlet 3.0 runtime behavior in one of the three ways described in LPS-75948.