Created
July 22, 2018 22:17
-
-
Save cmaggiulli/db1603b9a04e4e50a29c2599560efe1d to your computer and use it in GitHub Desktop.
Another example of multi upload and search container using JavaScript SDK and Java SDK Liferay 6.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aui:script use="liferay-upload"> | |
var uploader = new Liferay.Upload( | |
{ | |
boundingBox: '#<portlet:namespace />fileUpload', | |
<% | |
DecimalFormatSymbols decimalFormatSymbols = DecimalFormatSymbols.getInstance(locale); | |
%> | |
decimalSeparator: '<%= decimalFormatSymbols.getDecimalSeparator() %>', | |
fallback: '#<portlet:namespace />fallback', | |
fileDescription: '<%= StringUtil.merge(PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA)) %>', | |
maxFileSize: '<%= PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE) %> ', | |
namespace: '<portlet:namespace />', | |
removeOnComplete: true, | |
'strings.uploadsCompleteText': '<%= LanguageUtil.get(request, "all-files-are-saved") %>', | |
uploadFile: '<liferay-portlet:actionURL doAsUserId="<%= user.getUserId() %>" name="/wiki/edit_page_attachment"><portlet:param name="<%= Constants.CMD %>" value="<%= Constants.ADD %>" /><portlet:param name="nodeId" value="<%= String.valueOf(node.getNodeId()) %>" /><portlet:param name="title" value="<%= wikiPage.getTitle() %>" /></liferay-portlet:actionURL>&ticketKey=<%= ticket.getKey() %><liferay-ui:input-permissions-params modelName="<%= WikiPage.class.getName() %>" />' | |
} | |
); | |
uploader.on( | |
'uploadComplete', | |
function(event) { | |
var searchContainer = Liferay.SearchContainer.get('<portlet:namespace />pageAttachments'); | |
if (searchContainer) { | |
var rowColumns = []; | |
var deleteURL = Liferay.PortletURL.createURL('<%= deleteURL.toString() %>'); | |
deleteURL.setParameter('fileName', event.name); | |
rowColumns.push(event.name); | |
rowColumns.push(uploader.formatStorage(event.size)); | |
rowColumns.push('<a href="' + deleteURL + '"><%= TrashUtil.isTrashEnabled(scopeGroupId) ? UnicodeLanguageUtil.get(resourceBundle, "move-to-the-recycle-bin") : UnicodeFormatter.toString(removeAttachmentIcon) %></a>'); | |
searchContainer.addRow(rowColumns, event.id); | |
searchContainer.updateDataStore(); | |
} | |
} | |
) | |
</aui:script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment