Last modified by Thomas Mortagne on 2023/10/13

From version 48.3
edited by Marius Dumitru Florea
on 2015/05/05
Change comment: There is no comment for this version
To version 49.1
edited by Marius Dumitru Florea
on 2015/05/05
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -151,13 +151,48 @@
151 151  
152 152  When upgrading make sure you compare your ##xwiki.cfg##, ##xwiki.properties## and ##web.xml## files with the newest version since some configuration parameters may have been modified or added. Note that you should add ##xwiki.store.migration=1## so that XWiki will attempt to automatically migrate your current database to the new schema. Make sure you backup your Database before doing anything.
153 153  
154 -== Issues specific to XWiki <version> ==
154 +== Loading JavaScript from WebJars with RequireJS ==
155 155  
156 -<issues specific to the project>
156 +[[WebJars integration>>extensions:Extension.WebJars Integration]], available since 6.0M1, allows us to use JavaScript code that has been packaged as JAR and which has been included in the XWiki WAR or installed as an extension. Until this version the URL used to access a resource from a WebJar was looking like this:
157 157  
158 +{{code language="none"}}
159 +/xwiki/bin/webjars/resources/path?value=angularjs/1.2.11/angular.js
160 +{{/code}}
161 +
162 +The file path was specified in the query string. As a consequence, if you wanted to load a JavaScript file from a WebJar using RequireJS you would have written:
163 +
164 +{{code language="js"}}
165 +require(["$services.webjars.url('angularjs', 'angular.js')"], function() {
166 + ...
167 +});
168 +{{/code}}
169 +
170 +Note that the **'.js'** extension had to be included because RequireJS doesn't add it automatically if the URL has a query string. Starting with this version, the WebJar URLs look like this:
171 +
172 +{{code language="none"}}
173 +http://<server>/<context path>/webjars/<path/to/resource>[?version=<version>&evaluate=true|false]
174 +{{/code}}
175 +
176 +Note that the resource path is not included in the query string any more. This means you need to update the "require" calls:
177 +
178 +{{code language="js"}}
179 +require(["$services.webjars.url('angularjs', 'angular')"], function() {
180 + ...
181 +});
182 +{{/code}}
183 +
184 +Otherwise RequireJS will attempt to load "angular.js.js". **BUT** note that even with the new URL format there are still cases when the WebJar URLs have a query string: e.g. when the resource must be evaluated. In this case you need to keep the ".js" extension:
185 +
186 +{{code language="js"}}
187 +require(["$!services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar',
188 + 'require-config.min.js', {'evaluate': true})"], function() {
189 + ...
190 +});
191 +{{/code}}
192 +
158 158  == API Breakages ==
159 159  
160 -The following APIs were modified since <project> <version - 1>:
195 +The following APIs were modified since XWiki 7.0.1:
161 161  
162 162  {{code language="none"}}
163 163  <clirr output here>

Get Connected