Web UI Framework

How to Register a JavaScript Resource

Updated: October 16, 2020

This page talks about using JavaScript inside the Nuxeo web application (the back office). If you want to build a JavaScript application (with jQuery, Node, angularJS, ...) you should follow our Nuxeo JavaScript Client page.

To make a JavaScript resource available in your JSF page, you need to register the resource and to add to the theme view you are using.

Registering a JavaScript Resource

To register a JavaScript resource you give it a name a the path of the resource inside your JAR.

<extension target="org.nuxeo.theme.services.ThemeService"
point="resources">
<resource name="jquery.js">
<path>nxthemes/html/scripts/jquery.js</path>
</resource>

Using a Resource in a View

You can add a resource to the contribution of your view:

<extension target="org.nuxeo.theme.services.ThemeService" point="views">

<view name="myview" template-engine="jsf-facelets">
<format-type>widget</format-type>
<template>incl/includes.xhtml</template>
<resource>jquery.js</resource>
</view>
</extension>

JavaScript in WebEngine

If your webengine module extends either base or admin, then the prototype and jQuery libraries are already provided.

Available Javascript Libraries

It is not necessary to add resource for common JavaScript libraries as they are already contributed. We also recommand to use the libraries below if needed:

  • prototype 1.6.0.3
  • jQuery 1.4.4