Chapter 35. Module Scopes

The name of a logical portal module translates into an AMD name with a prefix of SHARED, PORTLET or PORTAL. This prefix fully identifies a module by its logical name and its scope. Scopes ensure that a module (and therefore the underlying web resource) is loaded at the right time when it is effectively required.

35.1. Shared Scope

The shared scope does not related to a specific portal entity, instead a shared module should be consumed by other modules. It is declared in gatein-resources.xml with the top level module tag:

<module>
  <name>core</name>
  <script>
    <path>/core.js</path>
  </script>
  <depends>
    <module>base</module>
  </depends>
</module>

35.2. Portal Scope

The module is related to a portal instance and is loaded when the related portal is accessed:

<portal>
  <name>classic</name>
  <module>
    <script>
      <path>/classic.js</path>
    </script>
    <depends>
      <module>core</module>
    </depends>
  </module>
</portal>

35.3. Portlet Scope

The module is loaded when the corresponding portlet is accessed:

<portlet>
  <name>sitemap</name>
  <module>
    <script>
      <path>/sitemap.js</path>
    </script>
    <depends>
      <module>core</module>
    </depends>
  </module>
</portlet>

Note

A module can only depend on a shared module, therefore any depends tags implicitly reference a shared module.