1

I have an Employee table which stores details of Employees (name,date of birth etc) I have a field in Employee table named fileEntryId which stores the Id of the employee pics which are stored in DL in liferay. What I want to do is if the fileEntryId in Employee matches with fileEntryId of the dlfileEntry table of the Document Library then display the images in the search container along with details from Employee table.

How to this?

EDITED:

I have a little problem here. All the images are displayed in each row. What I mean is suppose if I have 7 entries in the employee table (7 employees) then When I am displaying in the search container, all the 7 images are displayed for each employee

<!-- Code to display Employee Image -->


<%
 List <Employee> employee;
 employee= EmployeeLocalServiceUtil.getEmployees(-1,-1);
 String LImageId = String.valueOf(search.getFileEntryId());
 long ImageId = Long.valueOf(LImageId);
  for(Employee emp: employee) {
 DLFileEntry image = DLFileEntryLocalServiceUtil
 .getFileEntry(emp.getFileEntryId());
 String imageURL = "/documents/" + image.getGroupId() + "/" + image.getFolderId() + "/" + image.getTitle()+"/"+image.getUuid();
 %>

  <liferay-ui:search-container-column-text name="pic" href = "">
  <img src="<%=imageURL%>"/> 
 </liferay-ui:search-container-column-text>

I want one image per row. i.e. image of employee on every row..where am I going wrong?

Seeya K
  • 1,221
  • 6
  • 27
  • 43
  • I don't see anything out of the way to achieve this, if the `Employee` table is in the same Database as that of other Liferay tables then you can just write a custom-finder/custom-sql to fetch only those details of the `Employee` which have a corresponding file in the `DLFileEntry` table, a simple `JOIN` will do the trick. Please elaborate if this is not what you want. Thanks – Prakash K Apr 26 '13 at 05:52
  • @Prakash K: does custom-finder mean the finder methods? Could you provide me a good documentation for custom-query ? – Seeya K Apr 26 '13 at 06:26
  • 1
    @Seeya, you might have look at `DLUtil.getPreviewURL` to resolve your issues. one more option you can have is to store employee pics as Image rather as Document File, by that you can get image easily by `themeDisplay.getPortalURL()+themeDisplay.getPathImage()+"/image/?img_id="+imageId+"&t="+ WebServerServletTokenUtil.getToken(imageId)` – Pankaj Kathiriya Apr 26 '13 at 07:04
  • @Pankaj Kathiriya: I had initially tried storing the images in the Employee table. since it wasn't storing blob in service.xml i modified the model-hints file to store as long string and did all the modifications based on one tutorial. Images got stored but while retrieving only the long string instead of the image got displayed. so thought of going for DL – Seeya K Apr 26 '13 at 07:15
  • 1
    I mean to say to store imageId of Image instead fileEntryId of Document File. Even if you see Liferay's way of storing User Profile, it uses Image concept not Document File. – Pankaj Kathiriya Apr 26 '13 at 07:17
  • @Pankaj Kathiriya: Liferay 6.1 doesn't provide Image Gallery,that is what I read that they have merged it in DL. So how do I store it in Image? – Seeya K May 07 '13 at 12:51
  • @SeeyaK yes its true! It got merged with Document and Media portlet, but if you see image related api and database table is still there and being utilized, you can use them to fulfil your requirement. – Pankaj Kathiriya May 08 '13 at 05:10
  • @Pankaj Kathiriya: I found a way to solve this problem and it displays images but with problem.. I have added it in my question here in the EDITED Please check it and see if you can help.. In bried what happens is it is displaying images but displaying all the images in each row.. Check the code in my ques – Seeya K May 08 '13 at 06:12
  • 1
    This is not the right way to use search container. The elements under liferay-ui:search-container are getting iterated over list you provide in liferay-ui:search-container-results tag. So instead for loop simply get image for employee using modelVar available to you. modelVar will be iteration variable. write `String LImageId = String.valueOf(search.getFileEntryId());DLFileEntry image = DLFileEntryLocalServiceUtil .getFileEntry(LImageId ); String imageURL = "/documents/" + image.getGroupId() + "/" + image.getFolderId() + "/" + image.getTitle()+"/"+image.getUuid();` and remove for loop. HTH – Pankaj Kathiriya May 08 '13 at 06:48
  • @Pankaj Kathiriya: Thanks!! It worked!! I have upvoted your comment. Also have sent you request to connect on Liferay! Thanks again!! :) – Seeya K May 08 '13 at 07:18

0 Answers0