public JsResource generateWebResources() {
/**
* Main configuration file building
*/
JsResource mainJsFile = new JsResource(table.getId(), table.getOriginalId());
// Init the "configuration" map with the table informations
// The configuration may be updated depending on the user's choices
configGenerator = new DatatablesGenerator();
Map<String, Object> mainConf = configGenerator.generateConfig(table);
/**
* Extension loading
*/
logger.debug("Loading extensions...");
ExtensionLoader extensionLoader = new ExtensionLoader(table);
extensionLoader.loadExtensions(mainJsFile, mainConf);
/**
* Main configuration generation
*/
logger.debug("Transforming configuration to JSON...");
// Allways pretty prints the JSON
try {
Writer writer = new JsonIndentingWriter();
JSONValue.writeJSONString(mainConf, writer);
mainJsFile.appendToDataTablesConf(writer.toString());
} catch (IOException e) {
throw new WebResourceGenerationException("Unable to generate the JSON configuration", e);
}
return mainJsFile;