Alfresco 调试器无法打开包含导入标签的 js

发布于 2024-12-15 14:17:51 字数 384 浏览 4 评论 0原文

我正在社区 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

我不会写诗 2024-12-22 14:17:51

“导入标签”不是有效的 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.

離殇 2024-12-22 14:17:51

我在 Alfresco JIRA 中提出了一个改进请求(或者更确切地说是贡献),它通过在 JavaScript 中提供一个干净的导入 API 来解决这个问题。如果您想尝试一下,您可以从 https 获取补丁文件作为附件: //issues.alfresco.com/jira/browse/ALF-13631

这样,您的示例

<import resource="classpath:/alfresco/xxx/xxx.js">

就变成了

importScript("legacy", "classpath:/alfresco/xxx/xxx.js", true); //Repository tier
importScript("classpath:/alfresco/xxx/xxx.js", true); //Share tier

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

<import resource="classpath:/alfresco/xxx/xxx.js">

becomes

importScript("legacy", "classpath:/alfresco/xxx/xxx.js", true); //Repository tier
importScript("classpath:/alfresco/xxx/xxx.js", true); //Share tier
行雁书 2024-12-22 14:17:51

我从未尝试过,但我很确定调试器无法处理这些语句。调试器来自 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.

暮年 2024-12-22 14:17:51

如果可能,请尝试将实际的 javascript 代码分离到不同的 .js 文件中,如下所述:使用 Javascript 的 Alfresco Web 脚本 – 第 1 部分

构建 Web 脚本代码时的第一个挑战是如何
Alfresco 导入额外的 Javascript 文件。露天期待
主 Web 顶部的 xml 样式标签
脚本文件。这将破坏 javascript 验证、自动代码
缩进和其他重要的编辑器功能。

这可以通过将所有 Javascript 代码放在单独的文件中来解决,
仅在主 Web 脚本 .js 文件中保留导入声明。

当然,这只有在您完全控制网页脚本文件时才有效。

If possible, try to separate the actual javascript code into different .js files as described here: Alfresco Web Scripts using Javascript – Part 1.

The first challenge when structuring your Web script code is how
Alfresco imports additional Javascript files. Alfresco expects
xml-style tags at the top of the main Web
script file. This will break javascript validation, automatic code
indentation and other important editor features.

This can be solved by placing all Javascript code in separate files,
leaving only the import declarations in the main Web script .js file.

Of course, this only works if you got full control over the webscript files..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文