Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
M. Garcia
View document from Asset Publisher in Document library
29 luglio 2011 4.51
Risposta

M. Garcia

Punteggio: Regular Member

Messaggi: 107

Data di Iscrizione: 17 maggio 2011

Messaggi recenti

Hello,

I'm trying to change behaviour for viewFullContentURL in an AssetPublisher display mode, say MyDisplay.
My Asset Publisher is on Home page.

I would like this link to redirect to the document library portlet on another page, Documents page.

I need to get from the AssetEntry :
  • the file ID
  • the folder ID


With this I should be able to modify the struts_action parameter of the link with "document_library/view/<folderID>/<fileID>.

I managed to do this with Web Content, ie viewing full content of the Article in another Asset Publisher in another page.

But with the document library you need the folderID and the fileID, which I can't see a way to retrieve from the AssetEntry.

Any idea ?

Thanks a lot !
Hitesh Methani
RE: View document from Asset Publisher in Document library
30 luglio 2011 10.38
Risposta

Hitesh Methani

Punteggio: Regular Member

Messaggi: 113

Data di Iscrizione: 24 giugno 2010

Messaggi recenti

Hi Garcia,

From AssetEntry object you can get ClassPk and that classPK will be dlFileEntryId,
Using that id you can get a DLFileEntry object which will help you to get the folderId for that document.

So you will have folderId and fileEntryId in hand, and for creating url for downloading the document itself
you can refer my blog http://hiteshmethani.blogspot.com/2011/06/creation-of-urls-for-entities-in.html.

Thanks,
Hitesh Methani.
M. Garcia
RE: View document from Asset Publisher in Document library
1 agosto 2011 4.42
Risposta

M. Garcia

Punteggio: Regular Member

Messaggi: 107

Data di Iscrizione: 17 maggio 2011

Messaggi recenti

Hello Hitesh,

Thanks for your enlightment.

From AssetEntry object you can get ClassPk and that classPK will be dlFileEntryId,
Using that id you can get a DLFileEntry object which will help you to get the folderId for that document.


So this is DLFileEntryLocalServiceUtil.getFileEntry(pk).

I'm trying out, I'll let you know when I'm done (or stuck !). Thanks
M. Garcia
RE: View document from Asset Publisher in Document library
1 agosto 2011 5.58
Risposta

M. Garcia

Punteggio: Regular Member

Messaggi: 107

Data di Iscrizione: 17 maggio 2011

Messaggi recenti

Well,

I managed to get the DLFileEntry.
But I'm in trouble to make up the link to the document view in Document Library :

 1...
 2long docPK = assetEntry.getClassPK();
 3DLFileEntry dlFileEntry = DLFileEntryLocalServiceUtil.getFileEntry(docPK);
 4
 5%>
 6<liferay-portlet:renderURL var="viewFullContentURL" plid="10466">
 7    <liferay-portlet:param name="struts_action" value="/document_library/view_file_entry"></liferay-portlet:param>
 8    <liferay-portlet:param name="fileEntryId" value="<%= String.valueOf(dlFileEntry.getFileEntryId()) %>"></liferay-portlet:param>
 9</liferay-portlet:renderURL>
10<%
11...


So far, this moves the user on the "Documents" page (plid=10466) but shows document library at its root folder.
I want to see the document description page.

I tried also with struts_action "/document_library/view" but with same results.

Deploring the lack of Liferay's API documentation, I'm not sure which struts action I should use and how to build the URL, so I'm counting on your help !

Thanks =)
Hitesh Methani
RE: View document from Asset Publisher in Document library
1 agosto 2011 13.11
Risposta

Hitesh Methani

Punteggio: Regular Member

Messaggi: 113

Data di Iscrizione: 24 giugno 2010

Messaggi recenti

Hi Garcia,

Your struts action is correct but think you should also mention portlet name as the parameter.
Following is the required render url that you will need to create the link to the required document

1
2<liferay-portlet:renderURL var="viewFullContentURL" plid="<%= 10466 %>" portletName="<%= PortletKeys.DOCUMENT_LIBRARY %>">
3    <liferay-portlet:param name="struts_action" value="/document_library/view_file_entry"></liferay-portlet:param>
4    <liferay-portlet:param name="folderId" value="<%= String.valueOf(fileEntry.getFolderId()) %>"></liferay-portlet:param>
5    <liferay-portlet:param name="name" value="<%= HtmlUtil.unescape(fileEntry.getName()) %>"></liferay-portlet:param>
6</liferay-portlet:renderURL>


The parameters needed are folderId and name of the file entry.

This url will open up document description page.

Hope this will help you.. emoticon

Regards,
Hitesh,
Cignex Technologies.
M. Garcia
RE: View document from Asset Publisher in Document library
2 agosto 2011 1.23
Risposta

M. Garcia

Punteggio: Regular Member

Messaggi: 107

Data di Iscrizione: 17 maggio 2011

Messaggi recenti

Thanks a lot Hitesh !

It's up and running =)

Last thing, what is the way to set the "back to ..." link which is showed in the doc library ?
For example if I want this back link to return the user to the page he was before he wanted to see the document in the doc library.

Thanks !
Hitesh Methani
RE: View document from Asset Publisher in Document library
2 agosto 2011 21.21
Risposta

Hitesh Methani

Punteggio: Regular Member

Messaggi: 113

Data di Iscrizione: 24 giugno 2010

Messaggi recenti

Hi Garcia,

The code in view_file_entry.jsp of document library says, the back link will always redirect to view parent folder of the file,
so if you want back button to behave differently, you will have to write a hook for document library, that will set the back url to previous url instead by reading the parameter value that you will set to current url while redirecting.

All you have to do is set an extra parameter while rendering the view document, read the value of that parameter in view_file_entry.jsp of document library hook and set the back url accordingly.

Hope this will help you out.

Regards,
Hitesh.
Cignex Technologies
M. Garcia
RE: View document from Asset Publisher in Document library
3 agosto 2011 1.01
Risposta

M. Garcia

Punteggio: Regular Member

Messaggi: 107

Data di Iscrizione: 17 maggio 2011

Messaggi recenti

Hey Hitesh,

Thanks a lot for the detailed explanation. =)