Friday, March 14, 2014

Migrating gadgets in Nuxeo 5.4.2 to Nuxeo 5.6 or later: How to do it

Gadgets are small blocks that can be added to the Nuxeo control panel, and which makes it easier for users to get certain information, such as the list of tasks pending, documents that have been opened recently, etc. so that the user can get this information quickly, and have it at his fingertips.

Sometimes, the needs of a business aren’t covered by the gadgets that are included by default in Nuxeo; because of that, new gadgets can be developed so that users or workers in the business can count on the information that they need. These gadgets will be part of a larger plug-in which could contain other gadgets.

The problem comes up when we try to migrate a gadget developed for Nuxeo 5.4.2, or a version that predates version 5.6 or an even earlier version of Nuxeo, given that the platform has changed the way in which it interprets gadgets.

As such, if we want our old gadget to keep functioning when we update the platform to a newer version, we need to follow a few simple steps that we’re going to describe below:

STEP 1

First, open the .xml file of the gadget that you want to migrate. You’ll generally find a list of scripts and various methods in this file.

Cut all the methods that you’ve got inside the .xml of the gadget so that you can paste them into another file.

STEP 2
Create a file with a .js extension (such as GADGET_SCRIPT.js) in /nuxeo.war/scripts/<PLUGIN>/gadgets/ and paste the section of code that you cut in Step 1.

STEP 3
Create a contribution in an .xml file, and after the dot in the "resources" extension of the "org.nuxeo.theme.services.ThemeService" component that indicates the route of the new .js file created in Step 2, and don’t forget to refer to this contribution from the “Nuxeo-Component” section of MANIFEST.MF  of the plug-in that the gadget belongs to.
que indique la ruta del nuevo fichero .js creado en el paso anterior y además referencia esta contribución desde la sección "Nuxeo-Component" del MANIFEST.MF del plugin al que pertenece el gadget.

STEP 4
In the gadget’s .xml file (the same one as in Step 1), you substitute the following in all of the lines of the scripts:

<script src="{...}NOMBRE_SCRIPT_1.js"></script>

<script src="{...}NOMBRE_SCRIPT_2.js"></script>
...


and exchange them with the one line of the code below:

<script src="{clientSideBarUrl}nxthemes-lib/gadget-NOMBRE_SCRIPT_1.js,gadget-NOMBRE_SCRIPT_2.js,..."></script>

STEP 5
Finally, add the last script you created to the previous list with the methods you extracted from the .xml file of the gadget. (In the example below, we’ve called the script "GADGET_SCRIPT.js"):

<script src="{clientSideBarUrl}nxthemes-lib/gadget-NOMBRE_SCRIPT_1.js,gadget-NOMBRE_SCRIPT_2.js,...,gadget-GADGET_SCRIPT.js"></script>

Share

No comments:

Post a Comment

AddThis