1

I want to display images which are present in the liferay Document Library.
How should I iterate to get all the images and display them?

The code that I have right now is :

<portlet:renderURL  var="viewImageDataURL"/>

<liferay-ui:search-container delta="20" emptyResultsMessage="No Results Found">
    <liferay-ui:search-container-results
            total="<%= employeeImages.size() %>"
            results="<%= ListUtil.subList(employeeImages, 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.getDLFileEntry(1)%>"/>'>
        </liferay-ui:search-container-column-text>
    </liferay-ui:search-container-row>

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

</liferay-ui:search-container>

How should I iterate? The function to diplay images from Document Library is getDLFileEntry(fileId), I want to display all the values.

Edited Code:

The code I used is:

<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.model.impl.DLFileEntry">
        <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>

The error is shown in the line below:

and the error description is:

com.liferay.portlet.documentlibrary.model.impl.DLFileEntry cannot be resolved to a type

Rasabihari Kumar
  • 491
  • 1
  • 4
  • 16
Seeya K
  • 1,221
  • 6
  • 27
  • 43

1 Answers1

1

The attribute value className , you provided for seems incorrect.

I believe results value would be list of type DLFileEntry in your case.

Here you could have specified className as Model name [com.liferay.portlet.documentlibrary.model.impl.DLFileEntry] you want to iterate in Search Container. keyProperty as some primary-key name for model,

<liferay-ui:search-container-row className="com.liferay.portlet.documentlibrary.model.impl.DLFileEntry" keyProperty="fileEntryId" modelVar="searchRow">

Now, searchRow can be treated as object of iteration.

You can call any getter method of model DLFileEntry to use it for display.

=============================================================================== <liferay-ui:search-container searchContainer="${searchContainerObj}"> <liferay-ui:search-container-results results="<%=LIST OF OBJECT OF DLFileEntry%>"/> <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-container>

Let me explain terminology of above code. liferay-ui:search-container-results tag will have list of object, you want to show in search-container. liferay-ui:search-container-row tag will define modelVar fileEntry, which will be iteration object of type of List objects. In body of liferay-ui:search-container-row , modelVar fileEntry will be available. Here if results List is of size 3 then 3 thumbnail images will be shown.

Pankaj Kathiriya
  • 4,210
  • 2
  • 19
  • 26
  • Thanks Pankaj for such a prompt reply and a nice explanation. I understood what you are saying about className. But could You explain with an example about resultrow, searchRow and results? – Seeya K Apr 17 '13 at 14:12
  • I have edited my code but it doesn't work I have pasted it above in my question itself under EDITEDCODE – Seeya K Apr 18 '13 at 04:25
  • Well Seeya, here search is object of type DLFileEntry. Also you cant use `` tag as a value of ``. In `` tag body , search object is available and you can utilize it to get any information. Also you can have other html syntax in`` tag. – Pankaj Kathiriya Apr 18 '13 at 06:15
  • Pankaj can you give me an example of how to use it? I am getting confused with it.. And how should I use getFileEntry(long imageid) function to pass id of every image? – Seeya K Apr 18 '13 at 06:34
  • I am still getting the same error that com.liferay.portlet.documentlibrary.model.impl.DLFileEntry cannot be resolved to a type – Seeya K Apr 18 '13 at 07:03
  • Pankaj in your above code, <%=LIST OF OBJECT OF DLFileEntry%> how do I implement it? I mean how should I call the objects?? Sorry for sounding dumb but I am very new to liferay and using it for my internship project.. – Seeya K Apr 18 '13 at 07:08
  • its the same `DLFileEntryLocalServiceUtil.getFileEntries(searchContainer.getStart(), searchContainer.getEnd())` – Pankaj Kathiriya Apr 18 '13 at 07:36
  • Ya thanks for that but now the error that I get is in the following line: The error is : The method getThumbnailSrc(FileEntry, FileVersion, DLFileShortcut, ThemeDisplay) in the type DLUtil is not applicable for the arguments (DLFileEntry, String, null, ThemeDisplay) – Seeya K Apr 18 '13 at 08:10
  • I still get the error that com.liferay.portlet.documentlibrary.model.impl.DLFileEntry cannot be resolved to a type I have it imported in my file. What is the cause of the problem? – Seeya K Apr 18 '13 at 09:03