Re: Retrieve list all files stored in the same folder
PIRONET BenoƮt <[email protected]> Tue, 24 Jun 2008 08:20:53 +0200
| Newsgroups | gmane.comp.cms.jahia.devel |
|---|---|
| Message-ID | <27112111568D6346939B1DABE49CD100CE89C1@lux-mail.lux.cronos-technologies.com> |
Hi all, Thank you for the information. Now, my main problem is to index the file that are in the folder as content= of the page where the folder is selected. = Are there some ways to do so and what is the best way ? Regards, Benoit Pironet -----Original Message----- From: [email protected] on behalf of Serge Huber Sent: Mon 23/06/2008 08:14 To: Here you can discuss and comment current and future developments of Jah= ia Subject: Re: [dev_list] Retrieve list all files stored in the same folder = Also please note that the DAVFileAccess API will change and be replaced = by a new one in the next major release of Jahia. We will be introducing = more generic APIs on top of multiple file repositories. This change will = not happen in the service packs (SP4, etc), but only in the next major = release. Regards, Serge Huber. Sergiy Shyrkov a =E9crit : > Hi, > > I assume, you are using Jahia 5.0 SP3. > > 1) You can create the "WebDAV folder selector" in your page using the = > following code: > > <input type=3D"text" name=3D"myFolder" id=3D"myFolder" value=3D""/> > <a href=3D"#select" > onclick=3D"javascript:{var pathSelector =3D window.open('= <%=3D = > request.getContextPath() = > %>/jsp/jahia/engines/webdav/webdavrepository.jsp?display=3Ddirectories_On= ly&htmlElementId=3DmyFolder', = > 'pathSelector_<%=3D request.getSession().getId()%>', = > 'resizable,height=3D800,width=3D600'); pathSelector.focus(); return false= ;}"> > Select folder > </a> > > It contains an input field (with ID) and a link to the folder selector, = > where you pass the ID of the input element to store the selected folder = > path. The only thing, your will need to remove the '/jahia/webdav' from = > the URL. > > 2) To get the folder path for the selected file (Jahia field of type = > 'File') you can use the following code: > I am using mainContent container as an example (see our = > corporate_portal_templates_v2/common/main_content.jsp). > The field name is 'image'. > > <%@ page import=3D"org.jahia.services.webdav.JahiaWebdavBaseService, > org.jahia.services.webdav.DAVFileAccess, > org.jahia.data.beans.RequestBean, > org.jahia.params.ProcessingContext, > org.jahia.data.files.JahiaFile, > org.apache.commons.io.FilenameUtils" %> > > <content:containerList name=3D'<%=3D"mainContentList" + id%>' = > id=3D"mainContentList"> > ... > <content:container id=3D"mainContent"> > ... > <logic:present name=3D"mainContent" property=3D"field(image)"> > <bean:define id=3D"image" name=3D"mainContent" = > property=3D"field(image).object"/> > <logic:present name=3D"image"> > <bean:define id=3D"filePath" name=3D"image" property=3D"realNam= e"/> > <% > String folderPath =3D = > FilenameUtils.getFullPathNoEndSeparator((String) = > pageContext.getAttribute("filePath")); > if (folderPath !=3D null && folderPath.length() !=3D 0) { > ProcessingContext jParams =3D ((RequestBean) = > request.getAttribute("currentRequest")).getParamBean(); > DAVFileAccess folderItem =3D = > JahiaWebdavBaseService.getInstance().getDAVFileAccess(jParams, folderPath= ); > %> > = > Here is the folder path of the selected file: <%=3D = > folderItem.getPath() %> > > <% > } > %> > </logic:present> > </logic:present> > ... > </content:container> > </content:containerList> > > > 3) You can get a list of files (and also sub folders) in your template = > JSP using the DAVFileAccess API = > (http://www.jahia.org/javadoc-dev_5/org/jahia/services/webdav/DAVFileAcce= ss.html) = > in the following way: > > <%@ page = > import=3D"org.jahia.services.webdav.JahiaWebdavBaseService,org.jahia.serv= ices.webdav.DAVFileAccess" = > %> > <h3>Content of the /shared/myfolder</h3> > <ul> > <% > DAVFileAccess myFolder =3D = > JahiaWebdavBaseService.getInstance().getDAVFileAccess(jParams, = > "/shared/myfolder"); > List children =3D myFolder.getChildren(); > for (Iterator it =3D children.iterator(); it.hasNext();) { > DAVFileAccess item =3D (DAVFileAccess) it.next(); > boolean isFolder =3D item.isCollection(); > %><li><a href=3D"<%=3D request.getContextPath() %>/webdav<%=3D = > item.getPath() %>" target=3D"_blank"><%=3D item.getName() %>[<%=3D isFold= er ? = > "folder" : "file" %>]</a></li><% > } > %> > </ul> > > > Kind regards > Sergiy > > PIRONET Beno=EEt schrieb: > = >> Hi, = >> >> I'd like to store lots of documents in different places in my file manag= er and let page creators (webmasters) to choose one directory and the templ= ate will be responsible for displaying all the files stored in that directo= ry. >> >> First question: = >> Is it possible to instanciate the file chooser to choose not a file but = a folder? = >> if I can't select a folder, I will ask page creator to select one file f= rom the directory we want to list all files and the processing will do the = job. >> By searching this way, I found that JahiaFile has a getFolderId() method= but I can't figure what I can do with the folder id ? >> >> Second question: = >> Is there an API to exploid the folder id retrieve from a JahiaFile ? >> >> >> >> Third question: How to get the list of file from one folder ?? >> I saw the jahiaWebdavBaseService but I'm not sure at all that I'm on the= right way? >> >> >> Thank you very much for your replies, = >> >> >> Benoit Pironet >> >> >> >> I'm using Jahia 5.0.3 >> _______________________________________________ >> dev_list mailing list >> [email protected] >> http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list >> = >> = > > _______________________________________________ > dev_list mailing list > [email protected] > http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list > > = _______________________________________________ dev_list mailing list [email protected] http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list _______________________________________________ dev_list mailing list [email protected] http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list