我们的目标是实现一个预填充的文档创建表单,其中包含从PluginService
对象中检索到的值。
当用户右键单击文档并选择“从此文档新建文档”时,它会触发一个Action
打开AddContentItemDialog
. 然后,调用该服务来检索所选文档的属性(也许没有必要,通过 Firefox 开发人员面板,我看到大多数,也许所有自定义属性都已获取)。
我可以填充文本字段属性,但不能填充ChoiceList
:它们不会更新,尽管它们可能会在内部填充。
这是一个带注释的代码示例:
require(["dojo/_base/declare",
"dojo/_base/lang",
"dojo/aspect",
"ecm/model/Request",
"ecm/widget/dialog/AddContentItemDialog"],
function(declare, lang, aspect, Request, AddContentItemDialog) {
// Parameters passed to the service as HttpServletRequest
// (Custom function)
var serviceParams = getServicesParams(items[0]);
// Object store and parentFolder retrieving (needed below)
var parentFolder = items[0].parent;
var objectStore = items[0].objectStore;
// Retrieving the template to use for the dialog
// (Custom function)
var entryTemplate = retrieveTemplate(objectStore, parentFolder);
// Service call
Request.invokePluginService("FormPlugin", "FormService", {
requestParams: serviceParams,
requestCompleteCallback: function(response) {
// Creating the global dialog box
var addContentItemDialog = new AddContentItemDialog();
// Box containing the document properties
var addContentItemPropertiesPane =
addContentItemDialog.addContentItemPropertiesPane;
// Box containing general stuff
var addContentItemGeneralPane =
addContentItemDialog.addContentItemGeneralPane;
// Showing the dialog box
addContentItemDialog.show(
repository,
parentFolder, /* parent folder */
true, /* document being added*/
false, /* not virtual */
null, /* no callback function */
null, /* no teamspace */
true, /* use an entry template */
entryTemplate, /* entry template */
true /* can't choose directory from another rep */
);
// Waiting for complete rendering before filling the properties and general fields
aspect.after(addContentItemPropertiesPane,
"onCompleteRendering",
function() {
// Setting the destination and lock it
var folderSelector = addContentItemGeneralPane.folderSelector;
folderSelector.setRoot(parentFolder, objectStore);
folderSelector .setDisabled(true);
// Property filling - Work :-)
addContentItemDialog.setTitle("New document from another");
addContentItemDialog.setIntroText("This form allow you to create a document from another one.");
addContentItemPropertiesPane.setPropertyValue("DocumentTitle", "Prefilled title");
// Property filling - Doesn't work :-(
addContentItemPropertiesPane.setPropertyValue("A_ChoiceList_Prop",
[ "Value\\1", "Value\\2", "Value\\3"]);
}, true);
}
});
});
});
也许我错过了一些神奇的 IBM 代码行来完成它。