有没有人在Liferay 6.1中尝试过多个文件上传。我试图以与6.0相同的方式做到这一点并且失败严重。我看到页面左上角的开始链接而不是portlet。当我单击并选择一些文件时,控件不会转到我的portlet。我检查了我的portlet.xml并验证了portlet类是否合适。这是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");
}
}
答案 0 :(得分: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>
希望这有帮助。