Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Seeya S Kudtarker
Display Images stored in Document Library using Search Container
April 17, 2013 10:17 PM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

I have stored images in Document Library and want to display them using search container.
The code that I have used is as follows:

<portlet:renderURL var="viewImageDataURL"/>
<liferay-ui:search-container delta="20" emptyResultsMessage="No Results Found">
<liferay-ui:search-container-results total="<%= DLFileEntryLocalServiceUtil.getDLFileEntriesCount() %>"
results="<%=DLFileEntryLocalServiceUtil.getFileEntries(searchContainer.getStart(), searchContainer.getEnd())%>" />
<liferay-ui:search-container-row modelVar="search"
className="com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil">

<liferay-ui:search-container-column-text name="ImageName" value = '<img src="<%=search.getDLFileEntries(searchContainer.getStart(), searchContainer.getEnd())%>"/>'>


</liferay-ui:search-container-column-text>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator searchContainer="<%=searchContainer %>" paginate="<%=true%>" />

</liferay-ui:search-container>


In the code above that I have quoted I guess I think there is some error. I do not understand where I am making mistake. className that I have used above is -
className="com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil" instead of com.liferay.portlet.documentlibrary.model.impl.DLFileEntry

What changes should I make?

Further for my project module, I have stored the fileentryId's in my Employee table and wish to access the photos of employees based on the employee. How hsould I iterate ?
Seeya S Kudtarker
RE: Display Images stored in Document Library using Search Container
April 18, 2013 2:08 AM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

I managed to use the following code to display the images that are present in the Document Library:

<portlet:renderURL var="viewImageDataURL"/>
<liferay-ui:search-container>
<liferay-ui:search-container-results results="<%=DLFileEntryLocalServiceUtil.getFileEntries(searchContainer.getStart(), searchContainer.getEnd())%>"/>
<liferay-ui:search-container-row className="com.liferay.portlet.documentlibrary.model.impl.DLFileEntry" keyProperty="fileEntryId" modelVar="fileEntry">
<img src="<%= DLUtil.getThumbnailSrc(fileEntry, fileEntry.getFileVersion(), null, themeDisplay) %>" />
</liferay-ui:search-container-row>

<liferay-ui:search-iterator searchContainer="<%=searchContainer %>" paginate="<%=true %>" />
</liferay-ui:search-container>


but the error that I get is:
com.liferay.portlet.documentlibrary.model.impl.DLFileEntry cannot be resolved to a type

I have it imported in my file.

What should the problem be? I cannot undetsand.
Rahul Pande
RE: Display Images stored in Document Library using Search Container
April 18, 2013 2:30 AM
Answer

Rahul Pande

Rank: Regular Member

Posts: 222

Join Date: July 6, 2010

Recent Posts

Hi Seeya,

Try putting com.liferay.portlet.documentlibrary.model.DLFileEntry in <liferay-ui:search-container-row> class name.

HTH
Rahul
Seeya S Kudtarker
RE: Display Images stored in Document Library using Search Container
April 18, 2013 2:35 AM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

Rahul,
first of thanks for the prompt replies you give emoticon
I had tried it before but the error given is :

The method getThumbnailSrc(FileEntry, FileVersion, DLFileShortcut, ThemeDisplay) in the type DLUtil is not
applicable for the arguments (DLFileEntry, DLFileVersion, null, ThemeDisplay)

Here is my code again:

<portlet:renderURL var="viewImageDataURL"/>
<liferay-ui:search-container>
<liferay-ui:search-container-results results="<%=DLFileEntryLocalServiceUtil.getFileEntries(searchContainer.getStart(), searchContainer.getEnd())%>"/>
<liferay-ui:search-container-row className="com.liferay.portlet.documentlibrary.model.DLFileEntry" keyProperty="fileEntryId" modelVar="fileEntry">
<img src="<%= DLUtil.getThumbnailSrc(fileEntry, fileEntry.getFileVersion(), null, themeDisplay) %>" />
</liferay-ui:search-container-row>

<liferay-ui:search-iterator searchContainer="<%=searchContainer %>" paginate="<%=true %>" />
</liferay-ui:search-container>
Seeya S Kudtarker
RE: Display Images stored in Document Library using Search Container
April 18, 2013 9:10 PM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

Hey Rahul,

It worked! It displays images. emoticon
Now I need to display it according to the employees that are selected..

Thanks anyways for the suggestions!!

Regards

Seeya
mohammad azaruddin
RE: Display Images stored in Document Library using Search Container
April 18, 2013 10:31 PM
Answer

mohammad azaruddin

Rank: Expert

Posts: 440

Join Date: September 17, 2012

Recent Posts

Hi
It would be helpfull to someone else if you attach working code here
Seeya S Kudtarker
RE: Display Images stored in Document Library using Search Container
April 18, 2013 10:37 PM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

yeah sure.. emoticon
I don't know if it is that efficient but here it is:


Btw mohammad, I made use of the code that you had given me last time to diplsay one image using fileId: thanks to you emoticon

<% String Download = ""; %>
<portlet:renderURL var="viewImageDataURL"/>
<liferay-ui:search-container>
<liferay-ui:search-container-results results="<%=DLFileEntryLocalServiceUtil.getFileEntries(searchContainer.getStart(), searchContainer.getEnd())%>"/>
<liferay-ui:search-container-row className="com.liferay.portlet.documentlibrary.model.DLFileEntry" keyProperty="fileEntryId" modelVar="fileEntry">
<img src="<%=Download = themeDisplay.getPortalURL()
+ themeDisplay.getPathContext()
+ "/documents/"
+ themeDisplay.getScopeGroupId()
+ StringPool.SLASH
+ fileEntry .getFolderId()
+ StringPool.SLASH
+ HttpUtil.encodeURL(HtmlUtil.unescape(String
.valueOf(fileEntry .getTitle()))) + "?version="
+ fileEntry .getVersion() %>" />
</liferay-ui:search-container-row>

<liferay-ui:search-iterator searchContainer="<%=searchContainer %>" paginate="<%=true %>" />
</liferay-ui:search-container>



Suggest changes if you have better ideas..