Search code examples
javajavascriptalfrescoweb-scripting

Call js webscript from Java webscript in Alfresco


I have a problem. I need execute js webscript from Java webscript. I know, how do it:

req.getRuntime().getContainer().getRegistry().getWebScript("com/home/testJs/testJs.get").execute(req, res)

, but how to construct the new WebScriptRequest object? I need do it for rewrite request path. It's a really problem for me. Thank you.


Solution

  • In general, you should use WebScriptRequestURLImpl. Without any other detail, it's hard go any deeper.

    That said, it's in general a bad idea to go through yet another HTTP call to yourself to fix your problem, it's basically an indication of poor modularization or lack of code reuse.

    I'd rather move the piece of code that's common in both the JS and Java web scripts flows to be an Action, which you could invoke from both places without having to repackage the input parameters, or worse send them via HTTP.