Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Alex Nguyen
How can i show user upload in Document Library ?
March 15, 2010 12:09 AM
Answer

Alex Nguyen

Rank: Junior Member

Posts: 60

Join Date: September 16, 2008

Recent Posts

im using Document Library to store some document and i have some user can upload data but now i want know when he or she upload the data, the information of file will be:


name size download datetime user

can you help me ?

thanks so much.

Alex
Mazhar Anwar
RE: How can i show user upload in Document Library ?
March 15, 2010 1:58 AM
Answer

Mazhar Anwar

Rank: Regular Member

Posts: 125

Join Date: February 5, 2010

Recent Posts

Alex Nguyen:
im using Document Library to store some document and i have some user can upload data but now i want know when he or she upload the data, the information of file will be:


name size download datetime user

can you help me ?

thanks so much.

Alex
Hi Alex,

Documents entries are added to DLFileEntry table in Liferay, where you can find all related information for documents,

You can get more documents related information in TagsAsset table, since for each document upload, Liferay adds entries in tagsAssets table and maintain the counter for each asset downloads.

you can fetch the data from any of the above tables by using any custom-sql or using any existing Liferay API(As per requirement) in your portlet.

HTH,
Mazhar
Erik Andersson
RE: How can i show user upload in Document Library ?
March 15, 2010 3:48 AM
Answer

Erik Andersson

Rank: Junior Member

Posts: 38

Join Date: April 8, 2008

Recent Posts

Hi Alex,

I would use a model listener to tap into the event that a new document library entry has been made:

http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Portal+Hook+Plugins

Cheers,
Erik
Alex Nguyen
RE: How can i show user upload in Document Library ?
March 15, 2010 8:54 AM
Answer

Alex Nguyen

Rank: Junior Member

Posts: 60

Join Date: September 16, 2008

Recent Posts

Thank for your reply but

Im not still clearly.

Can you tell me the way to do it.

thanks.
Erik Andersson
RE: How can i show user upload in Document Library ?
March 15, 2010 10:07 AM
Answer

Erik Andersson

Rank: Junior Member

Posts: 38

Join Date: April 8, 2008

Recent Posts

You implement a model listener with a hook. Hooks and model listeners are described in the wiki post I linked to. Also, take a look at the SevenCogs hook that comes with your Liferay bundle to get a more handson grip on how hooks are used.

One thing has changed since Ray wrote the wiki post:
Now you don't register your model listener in the liferay-hook.xml file. You rather specify your model listener in a portal.properties file, and then register the portal.properties file in the liferay-hook.xml file.

1. To register a model listener - create a portal.properties file in your hook and specify your listener:
1value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntry=my.package.hook.listeners.DLFileEntryListener


2. Add your portal.properties to your liferay-hook.xml file:

1<hook>
2    <portal-properties>portal.properties</portal-properties>
3</hook>


3. Add your new listener class to your hook:

 1package my.package.hook.listeners;
 2import com.liferay.portal.ModelListenerException;
 3import com.liferay.portal.model.BaseModelListener;
 4import com.liferay.portlet.documentlibrary.model.DLFileEntry;
 5
 6public class DLFileEntryListener extends BaseModelListener<Group> {
 7
 8    public void onAfterCreate(DLFileEntry entry) throws ModelListenerException {
 9   
10        // The code you wish to be executed when a new entry has been made
11   
12        System.out.println("A new document library entry was created");
13   
14    }
15
16}


Hooks can be tricky to get at first. But play around with them for a while. Learning how they work unveils a lot of possibilities in Liferay.

Cheers,
Erik