Reputation: 97
I save uploaded image files in tomcat or portlet temporary directory, and I want to display them. I know their path in server file system, but how generate a right path for displaying it on portlet's page? It must become from smth like:
opt/liferay/tomcat-7.0.27/temp/28-Image-portlet/WEB-INF/classes/intech/webpro/kegor/image/Clipboard02.jpg
to
How to get it?
I know how it is done from portlets resources folder:
#{resource['images:smiley.jpg']}
But how to display image from some server directory in portlet?
Upvotes: 0
Views: 1022
Reputation: 1
If you only need to display content (without permission check), you can use Tomcat. Put file into /webapps/portlet-name/html/ (or temp/portlet-name/html/) directory. As a result: http://site.com/portlet-name/html/image.jpg
Upvotes: 0
Reputation: 3777
You can't access images from another server using #{resource['image']} , You can either
1) give the full image path in xhtml
2) Keep the image paths in CSSfile and use CSS classes in xhtml.
3) create a common util function or
ResourceHelper ApplicationScoped Bean that has something like
getResource(String imageName) which returns the correct URL. You
can then use it in your xhtml as
#{ResourceHelper.getResource('image.png')}
Upvotes: 0