Re: integrating Facebook JS SDK
Thanks for your very useful example, Carlos! On Sat, 09 Apr 2016 15:48:58 -0300, Carlos Montero Canabal wrote: In your controller class (.java) you can write this: javaScriptSupport.addModuleConfigurationCallback(new ModuleConfigurationCallback() { @Override public JSONObject configure(final JSONObject configuration) { final JSONObject facebookExports = new JSONObject(); facebookExports.put("exports", "FB"); configuration.getJSONObject("shim").put("facebook", facebookExports); final JSONObject paths = new JSONObject(); paths.put("facebook", "//connect.facebook.net/es_ES/sdk"); configuration.put("paths", paths); return configuration; } }); And in your module file: define(['facebook'], function(FB){ init = function(appId){ FB.init({ appId : appId, version: 'v2.5', xfbml : true }); } return { init: init } }); For example. I hope help you. Regards Carlos Montero El 9/4/2016, a las 14:11, Pavel Chernyak escribió: Greetings, Ilya. Here is my example for Yandex maps module. As you can see I define require.js config in module file. requirejs.config({ paths: { 'ymaps': '//api-maps.yandex.ru/2.1/?lang=ru-RU', 'geolib': 'map/geolib.min' }, "shim": { 'ymaps': { exports: 'ymaps' }, 'geolib' : { exports: 'geolib' } } }); define(["jquery", "ymaps", "geolib","./lodash.min","./graham_scan.min"], function ($, ymaps,geolib) { code... }); Pavel Chernyak. 9 апр. 2016 г. 15:05 пользователь "Ilya Obshadko" написал: Facebook recommends the following method to integrate FB SDK using AMD approach: https://developers.facebook.com/docs/javascript/howto/requirejs/v2.5 However I can't find any obvious way to configure RequireJS paths in Tapestry. Is there any way to do it? -- Ilya Obshadko -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: integrating Facebook JS SDK
On Sat, 09 Apr 2016 09:05:17 -0300, Ilya Obshadko wrote: Facebook recommends the following method to integrate FB SDK using AMD approach: https://developers.facebook.com/docs/javascript/howto/requirejs/v2.5 However I can't find any obvious way to configure RequireJS paths in Tapestry. Is there any way to do it? Yes. See JavaScriptSupport.addModuleConfigurationCallback(ModuleConfigurationCallback): http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/javascript/JavaScriptSupport.html#addModuleConfigurationCallback(org.apache.tapestry5.services.javascript.ModuleConfigurationCallback) ModuleConfigurationCallback has a single method, JSONObject configure(JSONObject configuration), which receives the Require.js configuration as a JSONObject file so you can modify it to your needs and return it. There's an example in the Tapestry's test webapps. -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: integrating Facebook JS SDK
In your controller class (.java) you can write this: javaScriptSupport.addModuleConfigurationCallback(new ModuleConfigurationCallback() { @Override public JSONObject configure(final JSONObject configuration) { final JSONObject facebookExports = new JSONObject(); facebookExports.put("exports", "FB"); configuration.getJSONObject("shim").put("facebook", facebookExports); final JSONObject paths = new JSONObject(); paths.put("facebook", "//connect.facebook.net/es_ES/sdk"); configuration.put("paths", paths); return configuration; } }); And in your module file: define(['facebook'], function(FB){ init = function(appId){ FB.init({ appId : appId, version: 'v2.5', xfbml : true }); } return { init: init } }); For example. I hope help you. Regards Carlos Montero > El 9/4/2016, a las 14:11, Pavel Chernyak escribió: > > Greetings, Ilya. > Here is my example for Yandex maps module. As you can see I define > require.js config in module file. > > requirejs.config({ paths: { 'ymaps': '//api-maps.yandex.ru/2.1/?lang=ru-RU', > 'geolib': 'map/geolib.min' }, "shim": { 'ymaps': { exports: 'ymaps' }, > 'geolib' : { exports: 'geolib' } } }); define(["jquery", "ymaps", > "geolib","./lodash.min","./graham_scan.min"], function ($, ymaps,geolib) { > code... }); > > Pavel Chernyak. > 9 апр. 2016 г. 15:05 пользователь "Ilya Obshadko" написал: > >> Facebook recommends the following method to integrate FB SDK using AMD >> approach: >> https://developers.facebook.com/docs/javascript/howto/requirejs/v2.5 >> >> However I can't find any obvious way to configure RequireJS paths in >> Tapestry. >> >> Is there any way to do it? >> >> -- >> Ilya Obshadko >>
Re: integrating Facebook JS SDK
Greetings, Ilya. Here is my example for Yandex maps module. As you can see I define require.js config in module file. requirejs.config({ paths: { 'ymaps': '//api-maps.yandex.ru/2.1/?lang=ru-RU', 'geolib': 'map/geolib.min' }, "shim": { 'ymaps': { exports: 'ymaps' }, 'geolib' : { exports: 'geolib' } } }); define(["jquery", "ymaps", "geolib","./lodash.min","./graham_scan.min"], function ($, ymaps,geolib) { code... }); Pavel Chernyak. 9 апр. 2016 г. 15:05 пользователь "Ilya Obshadko" написал: > Facebook recommends the following method to integrate FB SDK using AMD > approach: > https://developers.facebook.com/docs/javascript/howto/requirejs/v2.5 > > However I can't find any obvious way to configure RequireJS paths in > Tapestry. > > Is there any way to do it? > > -- > Ilya Obshadko >
Re: integrating Facebook JS SDK
Pavel, So you just manually add requirejs.config call in every module file that has external AMD dependencies? This is helpful - thanks a lot! On Sat, Apr 9, 2016 at 3:47 PM, Pavel Chernyak wrote: > Greetings, Ilya. > Here is my example for Yandex maps module. As you can see I define > require.js config in module file. > > requirejs.config({ paths: { 'ymaps': '//api-maps.yandex.ru/2.1/?lang=ru-RU > ', > 'geolib': 'map/geolib.min' }, "shim": { 'ymaps': { exports: 'ymaps' }, > 'geolib' : { exports: 'geolib' } } }); define(["jquery", "ymaps", > "geolib","./lodash.min","./graham_scan.min"], function ($, ymaps,geolib) { > code... }); > > Pavel Chernyak > -- Ilya Obshadko
Re: integrating Facebook JS SDK
Greetings, Ilya. Here is my example for Yandex maps module. As you can see I define require.js config in module file. requirejs.config({ paths: { 'ymaps': '//api-maps.yandex.ru/2.1/?lang=ru-RU', 'geolib': 'map/geolib.min' }, "shim": { 'ymaps': { exports: 'ymaps' }, 'geolib' : { exports: 'geolib' } } }); define(["jquery", "ymaps", "geolib","./lodash.min","./graham_scan.min"], function ($, ymaps,geolib) { code... }); Pavel Chernyak
Re: integrating Facebook JS SDK
UPD: the obvious workaround is downloading it locally and contributing to ModuleManager: @Contribute(ModuleManager.*class*) *public* *static* *void* contributeModuleConfigiration ( MappedConfiguration configuration, @Path("context:js/facebook/sdk.js") Resource facebookSdk ) { configuration.add ( "facebook", *new* JavaScriptModuleConfiguration ( facebookSdk ).exports ( "FB" ) ); } However that doesn't look like an elegant solution either. Are there any other options? On Sat, Apr 9, 2016 at 3:05 PM, Ilya Obshadko wrote: > Facebook recommends the following method to integrate FB SDK using AMD > approach: > https://developers.facebook.com/docs/javascript/howto/requirejs/v2.5 > > However I can't find any obvious way to configure RequireJS paths in > Tapestry. > > Is there any way to do it? > > -- > Ilya Obshadko > > > > -- Ilya Obshadko
integrating Facebook JS SDK
Facebook recommends the following method to integrate FB SDK using AMD approach: https://developers.facebook.com/docs/javascript/howto/requirejs/v2.5 However I can't find any obvious way to configure RequireJS paths in Tapestry. Is there any way to do it? -- Ilya Obshadko