Portlet 3.0 Opt-in

thumbnail
Steve Weiss, modified 4 Months ago.

Portlet 3.0 Opt-in

Regular Member Posts: 112 Join Date: 9/20/11 Recent Posts

I am trying to update a portlet to use the Portlet 3.0 spec. Portal version is DXP 2025.q1.7.  When I try the following code I get the following error message: Requires 3.0 opt-in

            PortletContext ctx = getPortletContext();
            int major = ctx.getMajorVersion();
            int minor = ctx.getMinorVersion();
            _log.info(ID + "Portlet API version = " + major + "." + minor);

            Map<String, String[]> paramMap = new HashMap<>();
            PortletParameters rparams = request.getRenderParameters();
            Set<String> pnames = rparams.getNames();
            Iterator<String> itr = pnames.iterator();
            while (itr.hasNext()) {
                String name = itr.next();
                String[] values = rparams.getValues(name);
                _log.info(ID + "param name = " + name + ", value(s) = " + Arrays.toString(values));
                paramMap.put(name, values);
            }

The output in the log is this:

2025-04-23 17:15:19.664 INFO  [http-nio-8080-exec-3][DataMailerPortlet:137] gov.nasa.hq.datamailer.web.1.3.0:doView: Portlet API version = 3.0
2025-04-23 17:15:19.666 ERROR [http-nio-8080-exec-3][DataMailerPortlet:163] gov.nasa.hq.datamailer.web.1.3.0:doView: Requires 3.0 opt-in

The portlet is configured with the @Component annotation:

@Component(
        configurationPid = "gov.nasa.hq.datamailer.portlet.internal.configuration.DataMailerConfiguration",
        configurationPolicy = ConfigurationPolicy.OPTIONAL,
        immediate = true,
        property = {
                "javax.portlet.version=3.0",
                "com.liferay.portlet.display-category=NASA",
                "com.liferay.portlet.header-portlet-css=/css/styles.css",
                "com.liferay.portlet.instanceable=true",
                "javax.portlet.display-name=Data Mailer",
                "javax.portlet.portlet-mode=text/html;view,edit",
                "javax.portlet.init-param.template-path=/",
                "javax.portlet.init-param.view-template=/jsp/view.jsp",
                "javax.portlet.init-param.viewdata-template=/jsp/viewData.jsp",
                "javax.portlet.init-param.edit-template=/jsp/pref/preferences.jsp",
                "javax.portlet.name=" + DataMailerPortletKeys.DATAMAILER,
                "javax.portlet.resource-bundle=content.Language",
                "javax.portlet.security-role-ref=power-user,user"
        },
        service = Portlet.class)

Any ideas on why this is not working?

thumbnail
Steve Weiss, modified 4 Months ago.

RE: Portlet 3.0 Opt-in

Regular Member Posts: 112 Join Date: 9/20/11 Recent Posts

This seems to be working correctly now. I no longer get the "requires opt in" error message. I have no idea why, I didn't change any of that code.

thumbnail
David H Nebinger, modified 2 Months ago.

RE: Portlet 3.0 Opt-in

Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts

The javax.portlet.version property was all you needed to enable the portlet 3 spec. You might have had to purge the osgi/state because that meta information sometimes doesn't change when it changes on the components, but if it's working now you should be fine.

Community
Company
Feedback