Sechanris
Sechanris

Reputation: 332

Getting the URL for a file's metadata page in Liferay

I've been tasked with creating a new column in the list of files in a Liferay 6.2 document library. For each file, that column should display a link with the text "Details" and the URL for that file's metadata page. In view_entries.jsp, I'm looking to add this field to a ResultRow. All I've been able to find so far, is DLUtil's getPreviewURL, which only seems to give me the URL for downloading the file itself, rather than leading to the metadata page. The Title column uses a TextSearchEntry, which ends up displaying with the URL I want, but I can't figure out how to either get that URL from it or change the text it displays the link with.

Upvotes: 2

Views: 432

Answers (1)

Sechanris
Sechanris

Reputation: 332

PortletURL rowURL = liferayPortletResponse.createRenderURL();
rowURL.setParameter("struts_action", "/document_library/view_file_entry");
rowURL.setParameter("redirect", HttpUtil.removeParameter(currentURL,  liferayPortletResponse.getNamespace() + "ajax"));
rowURL.setParameter("fileEntryId", String.valueOf(fileEntry.getFileEntryId()));

In this code, fileEntry is the current document. To get the URL to the preview page, it's just rowURL.toString().

Upvotes: 1

Related Questions