3

有没有人在 Liferay 6.1 中尝试过多个文件上传。我试图以与 6.0 相同的方式进行操作,但失败得很厉害。我看到页面左上角的开始链接而不是 portlet。当我单击它并选择一些文件时,控件不会转到我的 portlet。我检查了我的 portlet.xml 并验证了 portlet-class 是否正确。这是jsp中的片段

<liferay-portlet:actionURL doAsUserId="<%= user.getUserId() %>" windowState="pop_up" name="uploadFile" var="uploadFileURL" >
    <portlet:param name="jspPage" value="/html/fileuploadportlet/view.jsp" />
</liferay-portlet:actionURL>


<div class="lfr-dynamic-uploader">
        <div class="lfr-upload-container" id="<portlet:namespace />fileUpload"></div>
    </div>
<div id="<portlet:namespace/>fallback"></div>
<aui:script use="liferay-upload">
    new Liferay.Upload({
        allowedFileTypes: '<%= StringUtil.merge(PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA)) %>',
        container: '#<portlet:namespace />fileUpload',
        maxFileSize: <%=Long.parseLong(PrefsPropsUtil.getString(PropsKeys.DL_FILE_MAX_SIZE)) %> / 1024,
        namespace:'<%=renderResponse.getNamespace()%>',
        uploadFile: '<%=uploadFileURL.toString()%>',
        buttonHeight: 100,
        buttonText: 'BEGIN',
        buttonWidth: 100,
        onFileComplete: function(){alert('fileComplete');},
        onUploadError: function(){alert('error');}
    });
</aui:script>

这是我的 portlet 的 processAction 方法

@Override
    public void processAction(ActionRequest actionRequest,
            ActionResponse actionResponse) throws IOException, PortletException {
        System.out.println("Something");
        UploadPortletRequest uploadRequest=PortalUtil.getUploadPortletRequest(actionRequest);
        File file =uploadRequest.getFile("file");
        System.out.println(file.getName());
        for(int i=0;i<50000;i++){
            System.out.println("Something");
        }

    }

截屏

4

1 回答 1

2

你能检查你<aui:script>是否正确,下面是 html/portlet/document_library/upload_multiple_file_entries.jsp 中显示的内容,我认为你缺少属性tempFileURL

    <aui:script use="liferay-upload">
        new Liferay.Upload(
            {
                allowedFileTypes: '<%= allowedFileExtensions %>',
                container: '#<portlet:namespace />fileUpload',
                deleteFile: '<liferay-portlet:actionURL doAsUserId="<%= user.getUserId() %>"><portlet:param name="struts_action" value="/document_library/edit_file_entry" /><portlet:param name="<%= Constants.CMD %>" value="<%= Constants.DELETE_TEMP %>" /><portlet:param name="folderId" value="<%= String.valueOf(folderId) %>" /></liferay-portlet:actionURL>&ticketKey=<%= ticket.getKey() %><liferay-ui:input-permissions-params modelName="<%= DLFileEntryConstants.getClassName() %>" />',
                fileDescription: '<%= StringUtil.merge(PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA)) %>',
                maxFileSize: '<%= PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE) %> B',
                metadataContainer: '#<portlet:namespace />commonFileMetadataContainer',
                metadataExplanationContainer: '#<portlet:namespace />metadataExplanationContainer',
                namespace: '<portlet:namespace />',
                tempFileURL: {
                    method: Liferay.Service.DL.DLApp.getTempFileEntryNames,
                    params: {
                        groupId: <%= scopeGroupId %>,
                        folderId: <%= folderId %>,
                        tempFolderName: 'com.liferay.portlet.documentlibrary.action.EditFileEntryAction'
                    }
                },
                uploadFile: '<liferay-portlet:actionURL doAsUserId="<%= user.getUserId() %>"><portlet:param name="struts_action" value="/document_library/edit_file_entry" /><portlet:param name="<%= Constants.CMD %>" value="<%= Constants.ADD_TEMP %>" /><portlet:param name="folderId" value="<%= String.valueOf(folderId) %>" /></liferay-portlet:actionURL>&ticketKey=<%= ticket.getKey() %><liferay-ui:input-permissions-params modelName="<%= DLFileEntryConstants.getClassName() %>" />'
            }
        );
    </aui:script>

希望这可以帮助。

于 2012-06-08T14:02:40.400 回答