Portlet dependencies can be expressed in the
gatein-resources.xml
file, it forces to declare the portlet dependencies at packaging time when the corresponding war file is
created.
The JSR-286 specification provides a mechanism for modifying portal headers that can be used to load JavaScript files. Although this mechanism is portable, it has several drawbacks:
A script can be loaded multiple times, specially if two portlets in two different war files load the same scripts, the only way to identify a script is by its URL.
Scripts have to be loaded by the head section of the portal impacting front-end performances.
GateIn allows creating dynamic dependencies of a portlet at runtime, when the render phase of the portlet occurs:
public void render(RenderRequest req, RenderResponse resp) throws PortletException, IOException {
resp.setProperty("org.gatein.javascript.dependency", "base");
resp.addProperty("org.gatein.javascript.dependency", "common");
}
This code is equivalent to the following declaration:
<portlet>
<name>MyPortlet</name>
<module>
<depends>
<module>base</module>
</depends>
<depends>
<module>common</module>
</depends>
</module>
</portlet>