Legacy Knowledge Base
Published Jul. 2, 2025

Can I add custom permissions through resource-actions/default.xml in a Liferay JS widget generated by Liferay JS Generator?

Written By

Alfonso Crisci

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

Issue

  • After generating a JS widget through the Liferay JS Generator, there won't be an apparent way to leverage custom permissions, like it's possible through the resource-actions/default.xml file in a "traditional" portlet.

Environment

  • Liferay DXP 7.1+

Resolution

  • The custom permissions feature is not implemented in JS widgets as in traditional portlets. There are some ways to get around this:

    1. Use the "boilerplate" permissions on the widget
    You may use the already available permissions on a liferay-js-generator widget, a "boilerplate" should be available through the Configuration > Permissions menu

    2. Use the traditional NPM portlet bundler
    If the already available permissions are not sufficient, you shall use the "traditional" portlet structure instead. In the case of an MVC, simply through e.g.:

    blade create -t mvc-portlet -v 7.3 -p com.liferay.docs.mvcportlet -c MyMvcPortlet my-mvc-portlet-project

    Project starters for popular JS frameworks are also available through the NPM mechanism, for example:

    blade create -t npm-react-portlet -v 7.3 -p com.liferay.npm.react -c MyNpmReactPortlet my-npm-react-portlet

    or

    blade create -t npm-angular-portlet -v 7.3 -p com.liferay.npm.angular -c MyNpmAngularPortlet my-npm-angular-portlet

    3. Customize the liferay-js-generator build process to support the feature
    You might also want to go for customizing the liferay-js-generator building process and add support for default.xml. Please note that this would be part of Customizations, for which the assistance of the Liferay Support Team is limited.

    Once said that, the pure JavaScript portlet JAR files are true OSGi bundles, hence, if you manage to develop some logic inside that Liferay Portal understands (and makes sense in the context of pure JavaScript portlet) it will be taken into account. For example, a build step that takes place after liferay-npm-bundler and injects the resulting JAR with some XML configuration files could be implemented and that could in theory work.

Additional Information

  • For backend features in pure Liferay JS Generator projects, the tool currently provides only localization and configuration services, plus a section in the package.json where portlet headers can be injected in the same way they are defined in Java annotations. Any other functionality needed, apart from the above, must be implemented as a new feature, because the pure JavaScript portlets are registered with the portal by means of an intermediate Java module that implements those features on behalf of the JavaScript code.

 

Did this article resolve your issue ?

Legacy Knowledge Base