好的,所以我们知道Alfresco有标准表格,它随附。例如,默认的ad-hoc表单如下所示:
现在,如果我想自定义该表单,比如添加一个单独的 Items 字段,我将如何进行此操作?我的意思是,我想要一个只显示当前项目的字段。另一个字段显示同一空间中的所有相关项目。我有一个脚本将空格中的所有项目显示到该单数项目字段中,所以我认为我应该可以操作它,但我需要先添加其他项目字段才能这样做。
我一直试图搞砸一些XML文件,我已经设法在表单上显示一个额外的 Items 标签,但不是实际的框可以显示填充添加或填充全部删除。
我首先修改了 /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 文件中尝试了一些不同的配对,但这似乎是唯一一个导致至少显示额外标签< strong>项目,尽管没有其他组件。我只是想知道是否有人有任何定制这些表格的经验,和/或可能知道我在这里做错了什么?
答案 0 :(得分:3)
你能不能发布一些你想要实现的图片,也许你已经取得了什么成就?只是为了说清楚。 我不明白你为什么要在那里做一个工作时添加另一个字段“Items”。无论如何,ad-hoc表单是工作流的一部分,您是要更改工作流表单还是其他一些内容,例如节点的上传和更改属性?这些都是不同的东西。 在这两种情况下,您都应该使用 share-workflow-form-config.xml 或 share-config-custom.xml 等文件。 无论如何,你不能只是添加像“singlePackageItem”这样的组件而不在某个地方声明它。 id packageItems和set Items正在调用一个名为packageItems.ftl的文件,该文件公开您看到的表单。您可以在以下位置找到该文件:
/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/form/controls/workflow
与所有其他ftl文件一起公开您在工作流程中看到的表单。如果您想自定义表单,并公开一些自定义属性或字段,您应首先使用某些(工作流)内容建模,您可以在这里找到一个wiki: Custom Share Workflow UI
如果您可以更具体地了解您想要达到的目标,那就问一下,我可以看看我是否可以帮助您。
好吧,也许我误会了,但这是我的想法。您应该有一个带有脚本的控制器 js 文件,以及一个在字段中公开这些文档的模板文件 ftl 。编辑* 如果您使用 packageItems 表单字段,则使用Alfresco提供的表格作为开箱即用的表单。您应该实现自己的freemarker模板文件,该文件读取您的脚本并公开此列表以及您需要的单个文件。 您可以从查看Share中默认表单控件中的代码开始: '/露天/ Tomcat的/ web应用/共享/ WEB-INF /类/露天/站点webscripts /组织/露天/组件/形式/控制/' 然后,您可以从 share-workflow-form-config.xml 中回忆起您自己的ftl表单控件,如下所示:
<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="my:ListFiles" />
<show id="packageItems" />
<show id="wf:notifyMe" />
</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="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="my:ListFiles" set="items">
<control template="/org/alfresco/components/form/controls/workflow/customListItems.ftl" />
</field>**
<field id="packageItems" set="items" />
<field id="wf:notifyMe" set="other" />
</appearance>
</form>
</forms>
</config>