留言板

How to create fileurl in the modellistner

thumbnail
me liferay,修改在11 年前。

How to create fileurl in the modellistner

Junior Member 帖子: 25 加入日期: 11-12-14 最近的帖子
I have create model listener for the document liberary portlet's documents.
now my problem is I want to create the document url in that listener and all I have over there is fileentry object.
Any one has any idea?

I know it could be done like this.
String fileUrl = themeDisplay.getPortalURL() + themeDisplay.getPathContext() + "/documents/" + themeDisplay.getScopeGroupId() + "//" + folderId + "//" + HttpUtil.encodeURL(HtmlUtil.unescape(title));

but
problem is I am not able to access themeDisplay object in the listener class any guidance?
Please also refer this thread
http://www.liferay.com/community/forums/-/message_boards/message/22396633
thumbnail
Jitendra Rajput,修改在11 年前。

RE: How to create fileurl in the modellistner

Liferay Master 帖子: 875 加入日期: 11-1-7 最近的帖子
I dont know if its recommended solution or not . But i can give you some idea.
Most of the method to get document URL will require themeDisplay object. Even you can not construct URL if you don't have themeDisplay. (DLUtil.getPreviewURL())

One thing you can do . You can create a new custom servlet which will be called if you pass URL like this
https://test.liferay.com/c/document_library/getfile?fileEntryId=856736 
. To construct this kind of URL you dont need themeDisplay at all.

You have to create custom servlet which will read this URL pattern and based on fileEntryId . So if you hit this URL in browser you will be able to read/download requested document.