添加下载权限操作
為什么80%的碼農(nóng)都做不了架構(gòu)師?>>> ??
1.webapp-core中l(wèi)ayouts-contrib.xml添加
<widgetType name="wnfiledownloadList"> <configuration> <sinceVersion>7.3</sinceVersion> <title>Extended File</title> <description> <p> The file widget displays a file uploader/editor in create or edit mode, with additional message tag for errors, and a link to the file in other modes. </p> <p> Widgets using this type can provide properties accepted on a <nxu:inputFile /> tag in create or edit mode, and properties accepted on a <nxu:outputFile /> tag in other modes. </p> </description> <categories> <category>configuration_not_ready</category> </categories> <supportedModes> <mode>edit</mode> <mode>view</mode> </supportedModes> <fields> <list>false</list> <complex>false</complex> <supportedTypes> <type>blob</type> </supportedTypes> </fields> <properties> <layouts mode="view"> <layout name="file_widget_type_properties_view"> <rows> <row> <widget category="widgetTypeConf">file_downloadLabel</widget> </row> <row> <widget category="widgetTypeConf">file_iconRendered</widget> </row> </rows> </layout> </layouts> <layouts mode="edit"> <layout name="file_widget_type_properties_edit"> <rows> <row> <widget category="widgetTypeConf">required</widget> </row> <row> <widget category="widgetTypeConf">file_downloadLabel</widget> </row> <row> <widget category="widgetTypeConf">file_iconRendered</widget> </row> </rows> </layout> </layouts> </properties> </configuration> <property name="template">/widgets/wnfiledownloadList.xhtml</property> </widgetType> 2.webapp/widget中創(chuàng)建wnfiledownloadList.xhtml <f:subview xmlns:f="http://java.sun.com/jsf/core" xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jstl/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:nxh="http://nuxeo.org/nxweb/html" xmlns:nxu="http://nuxeo.org/nxweb/util" xmlns:nxd="http://nuxeo.org/nxweb/document" xmlns:nxl="http://nuxeo.org/nxforms/layout" id="#{widget.id}">
<c:if test="#{nxl:isLikeViewMode(widget.mode)}"> <nxu:set var="document" value="#{empty widgetProperty_document ? value : widgetProperty_document}"> <nxu:set var="blobXPath" value="#{empty widgetProperty_blobXPath ? widget.fieldDefinitions[0].propertyName : widgetProperty_blobXPath}"> <c:set var="blobHolder" value="#{blobHolderGenerator.getBlobHolder(document)}" /> <c:set var="isMainBlob" value="#{blobXPath == blobHolder.xpath}" /> <c:set var="blob" value="#{isMainBlob ? blobHolder.blob : field_0}" /> <c:set var="filename" value="#{empty field_1 ? blob.filename : field_1}" /> <c:set var="blobLength" value="#{blob.length}" /> <c:set var="fileUrl" value="#{nxd:fileUrl('downloadFile', document, isMainBlob ? 'blobholder:0' : blobXPath, filename)}" />
<nxu:set var="actions"value="#{documentActions.getBlobActions(document, blobXPath, blob)}"cache="true"> <c:if test="#{blobLength >= 0}"><c:if test="#{documentManager.hasPermission(currentDocument.getRef(),'ReadWrite')}"><nxh:outputLinkvalue="#{fileUrl}"styleClass="documentDownloadLink"><nxh:graphicImage value="/icons/download.png"/><h:outputText value="#{messages['下載']}"/></nxh:outputLink></c:if> <c:if test="#{!documentManager.hasPermission(currentDocument.getRef(),'ReadWrite')}"><nxh:graphicImage value="/icons/nodownload.png"/> <h:outputText value="#{messages['請申請下載']}"/> </c:if> </c:if><c:if test="#{blobLength lt 0}"><h:outputText value="#{filename}"/> </c:if></nxu:set> </nxu:set> </nxu:set></c:if> <c:if test="#{nxl:isBoundToEditMode(widget.mode)}"> <nxu:inputFile id="#{widget.id}_file" value="#{field_0}" filename="#{field_1}" required="#{widgetProperty_required}" editFilename="false" οnclick="#{widgetProperty_onclick}" οnchange="#{widgetProperty_onchange}" /> <h:message escape="false" styleClass="errorMessage" for="#{widget.id}_file" id="#{widget.id}_message" /> </c:if>
</f:subview>
3.webapp中widget/summary的wnbookslistscontent_widget_template.xhtml添加 .columnClasses6{ width: 50px }
columnClasses="columnClasses1,columnClasses2,columnClasses3,columnClasses4,columnClasses5,columnClasses6"
<h:column><f:facet name="header">#{messages['label.summary.download.fileaction']}</f:facet><c:if test="#{hasMainBlob}"> <nxl:widgetType name="wnfiledownloadList" mode="view" value="#{currentDocument}" field="#{currentDocumentAsBlobHolder.xpath}"/> </c:if></h:column> <h:column> <c:if test="#{!hasOtherBlobsepubfiles}"> <c:forEach items="#{currentDocument.files.epubfiles}" varStatus="loop"> <nxl:widgetType name="wnfiledownloadList" mode="view" value="#{currentDocument}" field="files:epubfiles/#{loop.index}/file" /><br/> </c:forEach> </c:if> </h:column> <h:column> <c:if test="#{!hasOtherBlobscoverpublicityfiles}"> <c:forEach items="#{currentDocument.files.coverpublicityfiles}" varStatus="loop"> <nxl:widgetType name="wnfiledownloadList" mode="view" value="#{currentDocument}" field="files:coverpublicityfiles/#{loop.index}/file" /> <br/>
</c:forEach>
</c:if> </h:column>
4.添加修改lang包 label.summary.download.fileaction=\u67e5\u770b label.summary.download.wnfiledownloadList=\u4e0b\u8f7d
轉(zhuǎn)載于:https://my.oschina.net/lccchn/blog/730645
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
- 上一篇: LeetCode26. Remove D
- 下一篇: 使用BootStrap制作用户登录UI