我使用的是jsf 2.2 primefaces 6.0,我已經實現了一個解決方案來顯示圖像與圓頂場所primefaces組件。現在的問題是我triying找到解決方案來下載圖像(remarque我是一個初學者程序員,從來沒有使用js)使用javascript保存圖像從primefaces的組合圖像
其中一個stackoverflow成員給了我一個代碼,但它不起作用,或者我無法實現它。
這裏的XHTML代碼:
<p:galleria value="#{demandeBean.demandeSelectionnee.images}"
panelWidth="500" panelHeight="313" showCaption="false"
autoPlay="false" var="image">
<p:graphicImage
value="http://localhost:18080/openCars/images/#{image}"
width="500" height="313" />
</p:galleria>
這裏所提出的解決方案與JS:
<script type="text/javascript">
function download() {
$('.ui-galleria-panel img').each(function() {
$(this).after("<a href='"+ $(this).attr('src') +"' download='nameOfImage.jpg' class='ui-button' style='position: absolute;right: 0;top: 0; padding: 5px 10px;background:rgba(255,255,255,0.7);'><i class='fa fa-download'></i></a>")
});
</script>
_「但它不起作用或者我無法實現它。」_這就像描述問題的最終用戶。像開發人員那樣對待它。發生了什麼,你看到按鈕出現了嗎?函數是否被調用?請縮小問題範圍。如果沒有我們要求各種澄清,現在我們需要廣泛/不清楚的方式 – Kukeltje