文件上传后重定向

时间:2015-07-10 09:04:30

标签: alfresco alfresco-share alfresco-webscripts

我创建了Java Backed WebScript,允许客户端通过POST上传文件。我可以成功上传文件,这些文件都按预期工作。 但是,一旦文件上传完毕,我想离开,重定向到上传文档的文档详细信息页面。

是否可以使用Java代码调用重定向,或者有一种方法可以将nodeRef放入WebScriptResponse并从Javascript中读取它? 目前我在Alfresco 4.2.c上工作。在我的* .html.ftl中我有:

<form method="post" id="${id}-form" enctype="multipart/form-data" action="${action}" enctype="multipart/form-data">
<input type="file" name="fileField">
<span id="${id}-form-submit" class="yui-button yui-submit-button">
     <span class="first-child">
         <button type="button">${msg("button.upload")} </button>
    </span>   

在.js文件中:

     this.widgets.submitButton = Alfresco.util.createYUIButton(this, "form-submit", null, {
          type: "submit"
      });

这是我的Java代码:

public class UploadWebScript extends AbstractWebScript
{
@Override
public void execute(final WebScriptRequest req, WebScriptResponse res)
{
    FormData form = (FormData) req.parseContent();  
    for (FormData.FormField field : form.getFields())
    {                                   
        String fileName = field.getFilename();      
        if (field.getIsFile())
        {
            /*...Some custom code for upoading document...
             Here I have documentNodeRef of the uploaded document.
            */
        }
    }
    res.getWriter().write("OK");
    /* I can put here 
    res.getWriter().write(documentNodeRef.toString());
    but I don't know how to access from Javascript. */
}
}

0 个答案:

没有答案