好的,所以我们知道 Alfresco 有标准的表格,它随附。例如,默认的 ad-hoc 表单如下所示:
现在,如果我想自定义该表单,比如添加一个单独的Items字段,我将如何去做呢?我的意思是,我想要一个只显示当前项目的字段。另一个字段显示同一空间中的所有相关项目。我有脚本可以将空间中的所有项目显示到单个项目字段中,所以我认为我应该能够操纵它,但我首先需要附加项目字段才能这样做。
我一直在尝试弄乱一些 XML 文件,并且我设法获得了一个额外的Items标签以显示在表单上,但不是可以使用Add填充或使用Remove All 取消填充的实际框。
我通过首先修改/opt/alfresco-4.0.d/tomcat/webapps/share/WEB-INF/classes/alfresco/form-config.xml来做到这一点:
<alfresco-config>
<plug-ins>
<element-readers>
<element-reader element-name="forms" class="org.alfresco.web.config.forms.FormsElementReader"/>
</element-readers>
<evaluators>
<evaluator id="node-type" class="org.alfresco.web.config.forms.NodeTypeEvaluator" />
<evaluator id="model-type" class="org.alfresco.web.config.forms.ModelTypeEvaluator" />
<evaluator id="task-type" class="org.alfresco.web.config.forms.TaskTypeEvaluator" />
<evaluator id="aspect" class="org.alfresco.web.config.forms.AspectEvaluator" />
</evaluators>
</plug-ins>
<config>
<forms>
<default-controls>
<type name="text" template="/org/alfresco/components/form/controls/textfield.ftl" />
<type name="mltext" template="/org/alfresco/components/form/controls/textarea.ftl" />
<type name="int" template="/org/alfresco/components/form/controls/number.ftl" />
<type name="float" template="/org/alfresco/components/form/controls/number.ftl" />
<type name="double" template="/org/alfresco/components/form/controls/number.ftl" />
<type name="long" template="/org/alfresco/components/form/controls/number.ftl" />
<type name="boolean" template="/org/alfresco/components/form/controls/checkbox.ftl" />
<type name="date" template="/org/alfresco/components/form/controls/date.ftl" />
<type name="datetime" template="/org/alfresco/components/form/controls/date.ftl">
<control-param name="showTime">true</control-param>
</type>
<type name="period" template="/org/alfresco/components/form/controls/period.ftl" />
<type name="any" template="/org/alfresco/components/form/controls/textfield.ftl" />
<type name="category" template="/org/alfresco/components/form/controls/category.ftl" />
<type name="content" template="/org/alfresco/components/form/controls/content.ftl" />
<type name="association" template="/org/alfresco/components/form/controls/association.ftl" />
<type name="association:cm:person" template="/org/alfresco/components/form/controls/authority.ftl" />
<type name="association:cm:authority" template="/org/alfresco/components/form/controls/authority.ftl" />
<type name="association:cm:authorityContainer" template="/org/alfresco/components/form/controls/authority.ftl" />
<type name="association:packageItems" template="/org/alfresco/components/form/controls/workflow/packageitems.ftl" />
<type name="association:singlePackageItem" template="/org/alfresco/components/form/controls/workflow/packageitems.ft" />
<type name="transitions" template="/org/alfresco/components/form/controls/workflow/transitions.ftl" />
<type name="taskOwner" template="/org/alfresco/components/form/controls/workflow/taskowner.ftl" />
<type name="mbean_operations" template="/org/alfresco/components/form/controls/jmx/operations.ftl" />
<!-- Data types that should always be rendered read-only -->
<type name="qname" template="/org/alfresco/components/form/controls/readonly.ftl" />
<type name="noderef" template="/org/alfresco/components/form/controls/readonly.ftl" />
<type name="childassocref" template="/org/alfresco/components/form/controls/readonly.ftl" />
<type name="assocref" template="/org/alfresco/components/form/controls/readonly.ftl" />
<type name="path" template="/org/alfresco/components/form/controls/readonly.ftl" />
<type name="locale" template="/org/alfresco/components/form/controls/readonly.ftl" />
</default-controls>
<constraint-handlers>
<constraint type="MANDATORY" validation-handler="Alfresco.forms.validation.mandatory" event="keyup" />
<constraint type="NUMBER" validation-handler="Alfresco.forms.validation.number" event="keyup" />
<constraint type="MINMAX" validation-handler="Alfresco.forms.validation.numberRange" event="keyup" />
<constraint type="LIST" validation-handler="Alfresco.forms.validation.inList" event="blur" />
<constraint type="REGEX" validation-handler="Alfresco.forms.validation.repoRegexMatch" event="keyup" />
<constraint type="LENGTH" validation-handler="Alfresco.forms.validation.length" event="keyup" />
</constraint-handlers>
</forms>
</config>
</alfresco-config>
这里唯一真正的变化是增加了<type name="association:singlePackageItem" template="/org/alfresco/components/form/controls/workflow/packageitems.ft" />
.
接下来,我进入/opt/alfresco-4.0.d/tomcat/webapps/share/WEB-INF/classes/alfresco/share-workflow-form-config.xml ,修改如下:
<alfresco-config>
<!-- ************************************** -->
<!-- Workflow Definition Form Configuration -->
<!-- ************************************** -->
<!--
When workflows are started some bpm:workflowXxx properties are copied to the task and named bpm:xxx
I.e The bpm:workflowDueDate workflow property becomes the bpm:dueDate task property.
-->
<!-- Ad Hoc Workflow Definition -->
<config evaluator="string-compare" condition="jbpm$wf:adhoc">
<forms>
<form>
<field-visibility>
<show id="bpm:workflowDescription" />
<show id="bpm:workflowDueDate" />
<show id="bpm:workflowPriority" />
<show id="bpm:assignee" />
<show id="packageItems" />
<show id="singlePackageItem" />
<show id="bpm:sendEMailNotifications" />
</field-visibility>
<appearance>
<set id="" appearance="title" label-id="workflow.set.general" />
<set id="info" appearance="" template="/org/alfresco/components/form/2-column-set.ftl" />
<set id="assignee" appearance="title" label-id="workflow.set.assignee" />
<set id="items" appearance="title" label-id="workflow.set.items" />
<set id="thisOneItem" appearance="title" label-id="workflow.set.items" />
<set id="other" appearance="title" label-id="workflow.set.other" />
<field id="bpm:workflowDescription" label-id="workflow.field.message">
<control template="/org/alfresco/components/form/controls/textarea.ftl">
<control-param name="style">width: 95%</control-param>
</control>
</field>
<field id="bpm:workflowDueDate" label-id="workflow.field.due" set="info" />
<field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info">
<control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
</field>
<field id="bpm:assignee" label-id="workflow.field.assign_to" set="assignee" />
<field id="packageItems" set="items" />
<field id="singlePackageItem" set="thisOneItem" />
<field id="bpm:sendEMailNotifications" set="other">
<control template="/org/alfresco/components/form/controls/workflow/email-notification.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
<!-- Activiti Ad Hoc Workflow Definition -->
<config evaluator="string-compare" condition="activiti$activitiAdhoc">
<forms>
<form>
<field-visibility>
<show id="bpm:workflowDescription" />
<show id="bpm:workflowDueDate" />
<show id="bpm:workflowPriority" />
<show id="bpm:assignee" />
<show id="packageItems" />
<show id="singlePackageItem" />
<show id="bpm:sendEMailNotifications" />
</field-visibility>
<appearance>
<set id="" appearance="title" label-id="workflow.set.general" />
<set id="info" appearance="" template="/org/alfresco/components/form/2-column-set.ftl" />
<set id="assignee" appearance="title" label-id="workflow.set.assignee" />
<set id="items" appearance="title" label-id="workflow.set.items" />
<set id="thisOneItem" appearance="title" label-id="workflow.set.items" />
<set id="other" appearance="title" label-id="workflow.set.other" />
<field id="bpm:workflowDescription" label-id="workflow.field.message">
<control template="/org/alfresco/components/form/controls/textarea.ftl">
<control-param name="style">width: 95%</control-param>
</control>
</field>
<field id="bpm:workflowDueDate" label-id="workflow.field.due" set="info" />
<field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info">
<control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
</field>
<field id="bpm:assignee" label-id="workflow.field.assign_to" set="assignee" />
<field id="packageItems" set="items" />
<field id="singlePackageItem" set="thisOneItem" />
<field id="bpm:sendEMailNotifications" set="other">
<control template="/org/alfresco/components/form/controls/workflow/email-notification.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
</alfresco-config>
同样,这里唯一真正的变化是在 的<show id="singlePackageItem" />
任何实例之后<show id="packageItems" />
添加,在 的<set id="thisOneItem" appearance="title" label-id="workflow.set.items" />
任何实例之后<set id="items" appearance="title" label-id="workflow.set.items" />
添加,以及在 的<field id="singlePackageItem" set="thisOneItem" />
任何实例之后添加<field id="packageItems" set="items" />
。
但这是结果:
现在,我不认为这会那么容易。但是,我在share-workflow-form-config.xml文件中尝试了一些不同的配对,但这似乎是唯一导致至少可见显示额外标签Items的配对,尽管没有其余标签组件。我只是想知道是否有人有自定义这些表单的经验,和/或可能知道我在这里做错了什么?