3

I'm looking to use a scoped configuration file in an Alfresco javascript webscript. I started with this wiki page, and it got me mostly there.

This jira page told me I needed to create a file spring-webscripts-config-custom.xml and place it in a META-INF folder i.e. in /shared/classes/META-INF/spring-webscripts-config-custom.xml. Fine. Got that working. I can load the file, and browse the configuration using the methods listed in the Jira page.

But those methods are a pain to use (childrenMap and getChild), and I'd rather use E4X to parse and query the XML configuration file. To do so, I'd need to get the configuration file as a string and pass it to

var conf = new XML( configStr );

Any ideas on how I can do this?

And a good E4X tutorial page

4

1 回答 1

2

恕我直言,无法使用 JS 支持的 webscript 实现您所描述的内容。您需要实现一个Java 控制器来访问配置文件并将其发送回客户端。

也就是说,将他们的内容暴露给外界并不是 Alfresco 配置文件的真正目的。如果您可以披露您正在尝试实现的更多细节,那么建议一些将配置数据公开给客户端的正确方法会更容易。


编辑

在明确范围后,我的建议是为您的 Web 脚本提供一个专用的 XML 配置文件,其中包含错误代码和消息之间的所有映射。如文档中所述,假设您的 Web 脚本在myscript.get.desc.xml. 然后您可以创建一个名为的文件myscript.get.config.xml,其中包含例如:

<messages>
  <message>
    <id>1</id>
    <desc>A long description here</desc>
  </message>
</messages>

然后,您可以在 JS 控制器中解析此类配置myscript.get.js

var myconfig = new XML(config.script);
于 2013-01-19T10:40:48.310 回答