2016-07-18 60 views
0

I have the following code:使用JSF for <a href="myPicture.png" .../>

<div id="links" class="links"> 
    <ui:repeat var="storageAttachment" 
     value="#{gallerySlideshowController.selectedStorageAttachmentList}" 
     varStatus="status"> 

       <a 
        href="https://farm9.static.flickr.com/8839/27742500683_1da5eca775_b.jpg" 
        title="Banana"> <p:graphicImage 
         title="#{storageAttachment.name}" cache="true" 
         value="#{galleryPictureThumbnailRequestController.pictureThumbnail}" 
         rendered="#{galleryPictureThumbnailRequestController.pictureThumbnail != null}"> 
         <f:param name="id" value="#{storageAttachment.uniqueId}" /> 
        </p:graphicImage> 
       </a> 
    </ui:repeat> 

How can I replace the link in <a href="https://farm9.static.flickr.com/8839/27742500683_1da5eca775_b.jpg" to my picture path? I have stored the path on my local PC for every storageAttachment item. For example: Object1: storageAttachment.path = C:/mypicture.png

So I need something like: href="#{storageAttachment.path}" -> But this is also not correct because I got http://C:/mypicture.png

我該怎麼做? 謝謝你的幫助。

+0

'storageAttachment.path'正在返回錯誤的值,如此簡單。它不應該返回完整的路徑名稱,而只會返回您想用作'href'的部分。 – EJP

+0

如果您的應用程序僅在本地使用,您可以使用'file'協議。 –

+0

不,它不僅是本地的....我如何更改galleryPictureThumbnailRequestController.pictureThumbnail(它是從類型public StreamedContent getPictureThumbnail()到一個鏈接? – internet

回答

0

PictureThumnailRequestcontroller.pictureThumbnailStreamedContend,沒有href方法或getHref之類的東西,但是,你可以得到圖像的InpuStream通過pictureThumbnail.getStream()。我想你試圖達到的是渲染圖像,但更大?

  1. 所以也許嘗試一個簡單的Servlet來render the image
  2. 使用Omnifaces更好輕鬆呈現。
+0

我嘗試創建一個這樣的組件:https:/ /github.com/blueimp/Gallery/blob/master/README.md但似乎我需要在href中的圖片的網址,或者你有任何其他想法? – internet