4

我在 Alfresco 的工作流程中集成了一个小程序。org/alfresco/components/form/controls/workflow/activiti-transitions.ftl我在这里创建了一个新按钮

  ...

    <button onclick="changePDF(); this.disabled=true; return false;"> Change </button>
    <div id="pdfTexto" style="width:1000px;height:1000px"></div>
        <div class="applet">
            <script type="text/javascript">
                deploy();
            </script>
        </div>
    </#if>

并且此按钮更改(通过小程序的 javascript)调用小程序的功能,即在相应工作流的文件中进行更改。在此之后,我想像"Approved"按钮accept标准一样放置。但是,我只想在更改生效后进行此操作。"ok"当更改完成(POST 请求完成)时,我的小程序返回 a ,在此之后,我想放置"Approved"并重定向到“接受”按钮重定向的同一页面。在简历中,在“ok”之后,进行接受按钮的操作。

我的小程序使用以下内容更新现有文档的内容: http://localhost:8080/share/proxy/alfresco/api/upload...

我怎样才能做到这一点?任何提示以获得更好的解决方案然后下面?

进化: 我正在努力做到这一点:

 var form = new FormData();
     form.append("prop_wf_reviewOutcome","Approve");
     form.append("prop_bpm_comment","good");
     form.append("prop_transitions","Next");
     var requestTask = new XMLHttpRequest();
         requestTask[Alfresco.util.CSRFPolicy.getHeader()] = Alfresco.util.CSRFPolicy.getToken();
         requestTask.open("POST", "http://localhost:8080/share/proxy/alfresco/api/task/"+ taskidVar+ "/formprocessor" + "?" + Alfresco.util.CSRFPolicy.getParameter() + "=" + encodeURIComponent(Alfresco.util.CSRFPolicy.getToken()));
         requestTask.send(form);

但缺少将页面重定向为“批准”按钮。

4

1 回答 1

5

首先,您需要定义您的行为:

package com.someco.alfresco.policy;

import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.ContentServicePolicies;
import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class DocumentUpdatePolicy implements ContentServicePolicies.OnContentUpdatePolicy {
    private final Log logger = LogFactory.getLog(getClass());

    private PolicyComponent policyComponent;    
    private NodeService nodeService;    

    public void init() {
        this.policyComponent.bindClassBehaviour(
                QName.createQName(NamespaceService.ALFRESCO_URI, "onContentUpdate"),
                ContentModel.TYPE_CONTENT,
                new JavaBehaviour(this, "onContentUpdate", Behaviour.NotificationFrequency.EVERY_EVENT));
    }

    @Override
    public void onContentUpdate(NodeRef nodeRef, boolean newContent) {

        logger.debug("Called on: " + nodeRef);
        if (null == nodeRef || !nodeService.exists(nodeRef)) {
            logger.error("Wrong nodeRef");
            /* This can happen in some circumstances */
            /* Do you want to just ignore it or do something ? You decide */
            return;
        }

        /* Here goes the code to update the task */
    }

    public void setPolicyComponent(final PolicyComponent policyComponent) {
        this.policyComponent = policyComponent;
    }

    public void setNodeService(NodeService nodeService) {
        this.nodeService = nodeService;
    }


}

比您需要在自定义 Spring 上下文中初始化它:

<bean id="onDocumentUpdatePolicy" class="com.someco.alfresco.policy.DocumentUpdatePolicy">
    <property name="policyComponent">
        <ref bean="policyComponent" />
    </property>
    <property name="nodeService">
        <ref bean="NodeService" />
    </property>
</bean>
于 2016-02-13T17:44:19.817 回答