1

好的,所以我们知道 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的配对,尽管没有其余标签组件。我只是想知道是否有人有自定义这些表单的经验,和/或可能知道我在这里做错了什么?

4

1 回答 1

3

您能否发布一些您正在努力实现的目标的图片,也许是您已经取得的成就?只是为了说清楚。我不明白当你已经有一个字段在做它的工作时,你为什么要添加另一个字段“项目”。无论如何,临时表单是工作流的一部分,您是否要更改工作流表单或其他一些东西,例如节点的上传和更改属性?这些是不同的东西。在这两种情况下,您都应该使用share-workflow-form-config.xmlshare-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: 自定义共享工作流 UI

如果您可以更具体地说明您想要实现的目标,请询问,我可以看看是否可以帮助您。

好吧,也许我误解了,但这是我的想法。您应该有一个带有脚本的控制器js文件,以及一个在字段中公开这些文档的模板文件ftl 。编辑* 如果您使用packageItems表单字段,则使用 Alfresco 提供的即用型表单。您应该实现自己的 freemarker 模板文件,该文件读取您的脚本并公开此列表和您需要的单个文件。您可以从查看 Share 中默认表单控件中的代码开始:'/Alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/form/controls/' 然后,您可以从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>
于 2012-09-05T09:05:21.293 回答