我有一个带有表单和文本字段的Tab GUI扩展。我想将表单字段的值保存到ApplicatioData。我在想一个调用安圭拉方法的“更新”按钮。
是否有安圭拉方法来做到这一点?我没有在安圭拉看到任何方法。开始代码:
var c = $display.getItem();
var uri = c.getId();
答案 0 :(得分:6)
Anguilla不公开任何(webservice或JavaScript)方法来一般性地修改ApplicationData。您必须提供自己的服务器端代码来设置ApplicationData。
因此,在我最后的需要中,我编写了一个简单的WCF Web服务来设置应用程序数据:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
[ServiceContract(Namespace= "ExtensionsModel.Services")]
public class ExtensionsService
{
[OperationContract]
[WebInvoke(Method = "POST",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
public void SetEnabled(string[] itemIDs, bool enabled)
{
using (var client = TridionCoreService.GetSessionAwareClient())
{
var appdata = new ApplicationData();
appdata.ApplicationId = "ext:IsEnabled";
appdata.Data = new ASCIIEncoding().GetBytes(enabled ? bool.TrueString : bool.FalseString);
foreach (var itemID in itemIDs)
{
client.SaveApplicationData(itemID, new[] {appdata});
}
}
}
}
在我的模型的配置文件中连接它:
<?xml version="1.0" encoding="utf-8" ?>
<Configuration> <!-- namespaces removed for readability -->
<resources cache="true">
<cfg:filters/>
<cfg:groups>
<cfg:group name="Extensions.Models">
<cfg:domainmodel name="Extensions.Models">
<cfg:services>
<cfg:service type="wcf">Services/ExtensionsService.svc</cfg:service>
</cfg:services>
</cfg:domainmodel>
</cfg:group>
</cfg:groups>
...
然后从我的command._execute
Extensions.Commands.DisableExtension.prototype._execute = function (selection) {
ExtensionsModel.Services.ExtensionsService.SetEnabled(selection.getItems(), false);
};