论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
me liferay
How to create fileurl in the modellistner
2013年3月7日 上午4:11
答复

me liferay

等级: New Member

帖子: 23

加入日期: 2011年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
Jitendra Rajput
RE: How to create fileurl in the modellistner
2013年3月7日 上午6:14
答复

Jitendra Rajput

等级: Liferay Master

帖子: 709

加入日期: 2011年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
1https://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.