Alfresco 调试器无法打开包含导入标签的 js
我正在社区 4.0.a 上的“共享”中实现自定义文档详细信息操作。 此操作使用充当 HTTP POST 处理程序的存储库 Web 脚本。
所以我去 /alfresco/service/api/javascript/debugger
启用js调试器工具。
但是,当我尝试手动打开 js 文件(例如 faces.post.json.js)时,它会引发语法错误。
它对任何以以下内容开头的 js 执行此操作:
<import resource="classpath:/alfresco/xxx/xxx.js">
是否有任何我应该注意的事项才能将此调试器与此类文件一起使用?
I'm implementing a custom document-details action in Share on community 4.0.a.
This action is using repository webscript that acts as an HTTP POST handler.
So I went to /alfresco/service/api/javascript/debugger
to enable the js debugger tool.
But when I try to open a js file manually like aspects.post.json.js it launches a syntax error.
it does it with any js that starts with:
<import resource="classpath:/alfresco/xxx/xxx.js">
Is there anything I should be aware of to use this debugger with such files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
“导入标签”不是有效的 JavaScript。这就是 JavaScript 语法感知编辑器抱怨的原因。正如 Florian 提到的,它在“整个”javascript 被输入到解释器(rhino)之前就被解决了。
尽管如此,如果 Alfresco 能够用有效的 javascript 替换这个标签以使工具满意,那就太好了 - 也许使用类似于 Node.js 提供的
require
函数的东西。The "import tag" is not valid javascript. Thats why javascript syntax aware editors complain. As Florian mentions, it is resolved before the "whole" javascript is fed to the interpreter (rhino).
Nevertheless, would be nice if Alfresco would replace this tag with valid javascript to make tools happy - maybe with something similiar to the
require
function node.js provides.我在 Alfresco JIRA 中提出了一个改进请求(或者更确切地说是贡献),它通过在 JavaScript 中提供一个干净的导入 API 来解决这个问题。如果您想尝试一下,您可以从 https 获取补丁文件作为附件: //issues.alfresco.com/jira/browse/ALF-13631
这样,您的示例
就变成了
I have opened an improvement request (or rather contribution) in the Alfresco JIRA which addresses this issue by providing a clean import API in JavaScript. In case you want to play around with it, you can grab the patch files as attachments at https://issues.alfresco.com/jira/browse/ALF-13631
With this, your example
becomes
我从未尝试过,但我很确定调试器无法处理这些语句。调试器来自 Rhino javascript 引擎,导入标签是 Alfresco 的扩展。它们在脚本实际在 Javascript 引擎中运行之前就已解决。
I have never tried it but I am pretty sure that the debugger can't handle the statements. The debugger comes from the Rhino javascript engine and the import tags are an extension from Alfresco. They are resolved before the script is actually run in the Javascript engine.
如果可能,请尝试将实际的 javascript 代码分离到不同的 .js 文件中,如下所述:使用 Javascript 的 Alfresco Web 脚本 – 第 1 部分。
当然,这只有在您完全控制网页脚本文件时才有效。
If possible, try to separate the actual javascript code into different .js files as described here: Alfresco Web Scripts using Javascript – Part 1.
Of course, this only works if you got full control over the webscript files..