Resource dependencies can be declared in ICEfaces to make sure the resources are loaded in the correct order. This feature is used in core, components and can be used for application resources as well.
The dependencies are declared in an XML file that is expected to be packaged within the library (jar), under META-INF/resource-dependency.xml path.
Each resource can declare its dependency to other resources. There are two types of dependencies:
The requires tag can be used to mark the resources that are required to be loaded before the defined resource. Specifying a resource as required will result in the resource being automatically loaded in the order prescribed by the resource-dependency.xml file(s). Using the requires tag is useful in cases where a resource is required on every page.
For example, B.js, C.js will be loaded before A.js if there are components in the page needing them. D.js will be loaded before A.js, regardless of the requirements components have.
Resources enclosed in a depends-on tag are not automatically loaded by the resource dependency subsystem, but when present on the page they will be loaded before the declared resource. That is, they must be loaded by the application when applicable, such as via an h:outputStylesheet or h:outputScript tag. When these resource are included on a page, they will be loaded in the order prescribed by the resource-dependency.xml file(s). Using the depends-on tag is useful in cases where it may not always be desirable to load a particular resource (on every page), but when it is present, it must be loaded in a prescribed order.
For example, B.js, C.js will be loaded before A.js. In case B.js or C.js are not required by any of the components in the page, A.js will still be loaded but without forcing the loading of its dependencies.
The META-INF/resource-dependency.xml file can contain multiple dependencies all found under the same root element:
ICEfaces will use the information found in all resource-dependency.xml files to order the resources referenced by the rendered page.
© Copyright 2017 ICEsoft Technologies Canada Corp.